News:

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

Main Menu

Who is the author of mod_recenttopics?

Started by SlammedDime, April 02, 2007, 04:32:12 PM

Previous topic - Next topic

SlammedDime

Or is it a collaborative effort?  I only ask because in going through the current version, there seems to be a few cosmetic things and could cause errors and break templates.  It also lacks SEF support, even for standard Joomla SEF, which seems easily curable.  Here are my thoughts/changes:

We need to add a global variable, then change up the $myurl variable so it works with sefReltoAbs...
Changeglobal $context, $txt, $scripturl, $mosConfig_dbprefix, $mosConfig_db, $db_name;
to global $context, $txt, $scripturl, $mosConfig_dbprefix, $mosConfig_db, $db_name, $mosConfig_sef;


Change$myurl = $_SERVER['PHP_SELF'] . "?option=com_smf&Itemid=" . $row[0]."&";
to if($mosConfig_sef=='1')
$myurl = basename($_SERVER['PHP_SELF']) . "?option=com_smf&Itemid=" . $row[0]."&";
else
$myurl = $_SERVER['PHP_SELF'] . "?option=com_smf&Itemid=" . $row[0]."&";

Secondly, add SEF to the array as its created and change the 'short_subject' to include the subject length parameter...
Changed $posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '&amp;action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '&amp;action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '&amp;topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG']#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
to $posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => sefReltoAbs($scripturl . '&amp;board=' . $row['ID_BOARD'] . '.0'),
'link' => '<a href="' . sefReltoAbs($scripturl . '&amp;board=' . $row['ID_BOARD'] . '.0') . '">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : sefReltoAbs($scripturl . '&amp;action=profile;u=' . $row['ID_MEMBER']),
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . sefReltoAbs($scripturl . '&amp;action=profile;u=' . $row['ID_MEMBER']) . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], $smf_rt_sublength),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => sefReltoAbs($scripturl . '&amp;topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new'),
'link' => '<a href="' . sefReltoAbs($scripturl . '&amp;topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG']) . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);


I also removed this line of code from the first case, since we can use the 'short_subject' array value for the subject...  $post['subject'] = strlen(un_htmlspecialchars($post['subject'])) > ($sublength+3) ? htmlspecialchars(substr(un_htmlspecialchars($post['subject']), 0, $smf_rt_sublength) . '...') : $post['subject'];


Next, make some cosmetic changes based on if the poster is shown or not and add SEF to the 'new' button/link, as well as relocate the button/link to before the title.  Because of the current way its coded, a row and/or column tag would be left open if the poster is not shown because of the brackets of the if statement...
Change  echo '<td valign="top"><a href="', $post['href'], '">', $post['subject'], '</a> ';
if ($smf_rt_showposter==1) {
    if ($smf_rt_postline==1) echo '<br />';
    echo  $txt[525], ' ', $post['poster']['link'], ' ', $post['new'] ? ' ' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '</td>';
}
to   echo '<td valign="top">', $post['new'] ? '' : '<a href="' . sefReltoAbs($scripturl . '&amp;topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new') . '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <a href="', $post['href'], '">', $post['short_subject'], '</a> ';
if ($smf_rt_showposter==1) {
    if ($smf_rt_postline==1) echo '<br />';
    echo  $txt[525], ' ', $post['poster']['link'], ' ';
    }
    echo '</td>';


and   echo '<tr><td valign="top"><a href="', $post['href'], '">', $post['subject'], '</a> ';
if ($smf_rt_showposter==1) {
    if ($smf_rt_postline==1) echo '</td></tr><tr><td>';
    echo $txt[525], ' ', $post['poster']['link'];' ', $post['new'] ? ' ' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '</td></tr>';
}
to   echo '<tr><td valign="top">', $post['new'] ? ' ' : '<a href="' . sefReltoAbs($scripturl . '&amp;topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new') . '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <a href="', $post['href'], '">', $post['short_subject'], '</a> ';
if ($smf_rt_showposter==1) {
    if ($smf_rt_postline==1) echo '</td></tr><tr><td>';
    echo $txt[525], ' ', $post['poster']['link'];
}
echo '</td></tr>';


and lastly   echo '<li><a href="', $post['href'], '">', $post['subject'], '</a> ';
if ($smf_rt_showposter==1) {
  if ($smf_rt_postline==1) echo '<li> ';
  echo $txt[525], ' ', $post['poster']['link'], ' ', $post['new'] ? ' ' : '<a href="' . $scripturl . '&amp;topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>';
  }
to   echo '<li>', $post['new'] ? ' ' : '<a href="' . sefReltoAbs($scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new') . '"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a> <a href="', $post['href'], '">', $post['short_subject'], '</a> ';
if ($smf_rt_showposter==1) {
  if ($smf_rt_postline==1) echo '<li> ';
  echo $txt[525], ' ', $post['poster']['link'];
  }


I think those were the only changes I made, and it works pretty well and doesn't break any templates.  I'm not trying to step on toes, just trying to help make things better and more user friendly.

I'm still trying to sort out a database issue with selecting the databases, which is why I originally started looking at the code for this.  For some reason, phpAdsNew will not retrieve any ads from its database if this module is loaded on the page before phpAdsNew invocation unless you switch to the phpAdsNew database, but even if you switch back to the joomla database, it throws errors all over the screen.  I haven't figured out why yet, but I'm working on it.

Edit: I guess phpAdsNew will not get info from its database after the smf login module either... I dunno... I'll keep hacking away.
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Sarge

Either Orstio or Kindred is the original author of mod_smf_recentTopics. I only carried on from their code. Basically, I just fixed the board exclusion bug and added the option of choosing between three display formats.

FYI, I also created a SEF version, but I just didn't submit it. You have integrated SEF using conditionals, which is much better.

The "cosmetic bugs" should be because of tab settings, I guess. I'll recheck the code and will come up with an update... which will also include a new feature: board inclusion. ;)

Thanks for your constructive criticism and improvement of this module. I plan to include some (maybe all) of your changes. Now that's what I call collaborative effort! :D 

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

Advertisement: