News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Improving Joomla-SMF modules

Started by kai920, October 03, 2007, 08:23:53 AM

Previous topic - Next topic

kai920

Just noticed in my SMF error logs after installing mod_smf_newTopics.php and mod_smf_recentTopics.php:

Quote
8: Undefined variable:  sublength
File: /home/public_html/modules/mod_smf_recentTopics.php
Line: 139

Quote8: Undefined variable:  exclude
File: /home/public_html/modules/mod_smf_newTopics.php
Line: 44

Quote8: Undefined variable:  sublength
File: /home/public_html/modules/mod_smf_newTopics.php
Line: 137

Any quick fixes?

rummie

best bet is to look at the code, or post a link to the module or attach it so that others may have a crack at it.
???? hmmm?


slightly off topic, I would LOVE for the error log feature in SMF to have an
"Ignore further errors from this USER/PROGRAM" for "TODAY/FOREVER"


kai920

Code (mod_smf_recentTopics.php lines 134-140) Select

switch ($smf_rt_display)
   {
      case 0:
     echo '<table border="0" class="', $smf_rt_moduleclass_sfx, '">';
     foreach ($posts as $post) {
        $post['subject'] = strlen(un_htmlspecialchars($post['subject'])) > ($sublength+3) ? htmlspecialchars(substr(un_htmlspecialchars($post['subject']), 0, $smf_rt_sublength) . '...') : $post['subject'];
        echo '<tr>';


Code (mod_smf_newTopics.php line 44) Select

if ($exclude=="") $exclude="0";


Code (mod_smf_newTopics.php lines 132-138) Select

    switch ($smf_nt_display)
    {
        case 0:
      echo '<table border="0" class="', $smf_nt_moduleclass_sfx, '">';
      foreach ($posts as $post) {
          $post['subject'] = strlen(un_htmlspecialchars($post['subject'])) > ($sublength+3) ? htmlspecialchars(substr(un_htmlspecialchars($post['subject']), 0, $smf_nt_sublength) . '...') : $post['subject'];
          echo '<tr>';


Orstio

if ($exclude=="") $exclude="0";


That one should probably look more like this:

if (!isset($exclude) || $exclude=="") $exclude="0";

kai920

Great, solved the line 44 problem in both modules. I will try to use a similar approach for the other errors.

Orstio

$sublength should probably be changed to $smf_rt_sublength

kai920

Quote from: Orstio on October 07, 2007, 10:10:16 PM
$sublength should probably be changed to $smf_rt_sublength

That didn't work. I noticed at the beginning there is this line present:

$smf_rt_sublength = $params->get( 'smf_rt_sublength' );

Orstio

Have you edited the module parameters yet?  For most modules, the parameters are completely empty until you edit the module params, and save once.

kai920

Quote from: Orstio on October 08, 2007, 12:32:18 AM
Have you edited the module parameters yet?  For most modules, the parameters are completely empty until you edit the module params, and save once.

Yep - I checked all the modules and they all have a number entered into the "Subject Length" box.

Orstio

And you've made sure to click Save?  As I said, just because there is a value there when you look, automatically populated from the XML file, does not mean that value is actually saved in the database as a parameter.

kai920

yep - definitely saved! I've opened up the module(s) a couple times and it's in there.

I have two copies of recentTopics module, with different values for the subject length parameter.

I have just one copy of newTopics module, and it also has a subject length parameter.

kai920

#11
Orstio, I changed the newTopics variable to smf_nt_sublength. Appears to have done the trick!

recentTopics should have smf_rt_sublength.

And for good measure, I went into my modules and clicked SAVE for each.

I think this can be marked as solved. Thanks again.

Maybe someone should update the modules?

rummie

Quote from: kai920 on October 08, 2007, 01:17:12 AM
Orstio, I changed the newTopics variable to smf_nt_sublength. Appears to have done the trick!

recentTopics should have smf_rt_sublength.

And for good measure, I went into my modules and clicked SAVE for each.

I think this can be marked as solved. Thanks again.

Maybe someone should update the modules?

???

That somebody looks like YOU doesnt it! :P ..hopefully your next post will have the module as an attachment! :)

kai920

Quote from: rummie on October 08, 2007, 08:35:55 PM
Quote from: kai920 on October 08, 2007, 01:17:12 AM
Orstio, I changed the newTopics variable to smf_nt_sublength. Appears to have done the trick!

recentTopics should have smf_rt_sublength.

And for good measure, I went into my modules and clicked SAVE for each.

I think this can be marked as solved. Thanks again.

Maybe someone should update the modules?

???

That somebody looks like YOU doesnt it! :P ..hopefully your next post will have the module as an attachment! :)


lol, yes it could be ME! but I'm not sure how to repackage it, etc.... certainly don't mind doing it, but a more 'official' coder would probably do a better job!

actually the next thing I want to do would be proper SEF urls in these modules. Maybe once I've figured that out I can update the modules :)

As it is now the URLs look like


http://www.kaitech.hk/index.php?option=com_smf&Itemid=71&&topic=1756.msg6714;topicseen#new


This is with SEF in Joomla turned on. and note the two &'s

rummie

hmmm.. well upload the original zip files, then attach the files you changed and I'll give it a go!

the other thing to do too is to look at how the urls are constructed - the bridge also has its part to play as well so thats another place we will probably have to look.

kai920

#15
Here are the links to the two original modules. >LINK< (newTopics and recentTopics)

Unfortunately I am not able to attach files here.

kai920

Quote from: rummie on October 09, 2007, 02:28:59 AM
the other thing to do too is to look at how the urls are constructed - the bridge also has its part to play as well so thats another place we will probably have to look.

Just noticed that in the module, the SEF URL generated to the board is fine, but the link to the post is not.

kai920

Some additional observations.

Code (line 31 of mod_smf_recentTopics.php) Select
$myurl = $_SERVER[\'PHP_SELF\'] . \"?option=com_smf&Itemid=\" . $row[0] . \"&\" ;

If I take out that \"&\" at the end, the topic URL changes from
http://localhost/index.php?option=com_smf&Itemid=71&&topic=1761.msg6718;topicseen#new
to
http://localhost/index.php?option=com_smf&Itemid=71&topic=1761.msg6718;topicseen#new

HOWEVER, the board\'s already SEF URL changes from
http://localhost/component/option,com_smf/Itemid,71/board,1.0
to
http://localhost/index.php?option=com_smf&Itemid=71?board=1.0

Going to see if I can figure out something but if anyone has ideas...

kai920

Ah-ha! Found the extra & at line 119:

         'href' => $scripturl . 'amp;topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',

should be

         'href' => $scripturl . 'topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',


So the next step is... why is the board's URL SEF but the topic URL not-SEF?

kai920

OK some more progress made, but I have some questions:

1) I added a global $mosConfig_sef to the top of the smf_recentTopics.php file. Is this an acceptable practice?

2) Is ";topicseen#new" required or is just "#new" enough for appending to the end of the URL?  I noticed the forums here only use #new.

My bridge currently sends notification emails with what appears to be an incorrect "/topic,1761.new/topicseen,topicseen#new". Which is the correct URL?


Advertisement: