TinyPortal

Development => Block Codes => Topic started by: Bjørn on August 17, 2005, 12:01:38 PM

Title: "recent topics" in SMF style
Post by: Bjørn on August 17, 2005, 12:01:38 PM
This is requested elsewhere, but I though I post it here. It essentially use the SSI function for collecting the recent topics, and lay them out like the threads overview of the forum.

- use a PHP type block and just insert the code down below.
- use it preferably on a centerblock or frontblock - since its quite wide.
- looks best with "do not use title/frame" for the block, it has it own titlebar.
- add board ID number like to the function if youw ant to narrow down the boards recent topics are taken from. change it to ssi_recentTopics('8', array('3','56') , 'array') where the numbers 3 and 56 are examples of board ID's.


       
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


edit: added a extra line on top, since errors were created.

[attachment deleted by admin]
Title: Re: "recent topics" in SMF style
Post by: Ray on August 17, 2005, 04:51:02 PM
Works good but will not uncheck the post after the post has been read
Title: Re: "recent topics" in SMF style
Post by: Nokonium on August 17, 2005, 05:30:29 PM
Ray
One of my posts was the "elsewhere" (http://www.tinyportal.net/smf/index.php?topic=583.msg4568#msg4568)ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ;)

If you check you will find that the read and unread post topics are reversed. If you read one shown as unread it will then have a 'New' but, yes, if you read one marked 'New' it doesn't change.
Title: Re: "recent topics" in SMF style
Post by: Ray on August 17, 2005, 06:36:59 PM
Ah! ok thanks
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 17, 2005, 10:45:55 PM
Changed the code..does it work better now?
Title: Re: "recent topics" in SMF style
Post by: Nokonium on August 17, 2005, 11:10:24 PM
Yup! they are the right way round again. Thanks Bloc

It was terribly confusing, when you are over 50 you have enough difficulty remembering what you've read anyway .....  ;)
Title: Re: "recent topics" in SMF style
Post by: Ray on August 18, 2005, 12:44:33 AM
Aye works OK now -- yep over 50 can be a pain sometimes lol -- like remembering how to get home from work
Title: Re: "recent topics" in SMF style
Post by: Ray on August 18, 2005, 01:13:29 AM
How hard would it be to change it To recent post and not topics -- just wondering? :-\
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 18, 2005, 01:32:29 AM
You mean like the "recent posts" on the forum? (action=recent)
Title: Re: "recent topics" in SMF style
Post by: Ray on August 18, 2005, 03:45:16 AM
yes on all forums that have permission to see the post

what Im looking for is here

Show forum-posts on frontpage from:(can pisck only one forum)

to be able to have more than one forum at a time.
Title: Re: "recent topics" in SMF style
Post by: sp0di on August 20, 2005, 02:37:01 PM
Also, it is possible to show this at the bottom rather than the top?  I have been looing for how to do that - but cannot seem to find it...
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 20, 2005, 04:38:23 PM
I think that depends on what you want at the top. What would you have above the recent topics?
Title: Re: "recent topics" in SMF style
Post by: Nokonium on August 21, 2005, 10:09:30 AM
I've nearly finished what I'm doing with the block code. Even one page should show as Pages: [1] but I haven't got the page number to display yet.

[code]ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  global $context, $settings, $options, $txt, $scripturl, $modSettings;
echo '
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder">
<tr><td class="titlebg">Recent topics</td></tr></table><table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder"><tr><td class="catbg">These are our most recent topics</td></tr></table>';


echo '
<table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="margin-bottom: 3px;margin-top: 3px;">
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <tr>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <td align="left" class="catbg" width="100%" height="35">
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <table cellpadding="3" cellspacing="0" width="100%">
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <tr>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <td>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ', $txt[139], ': ', $context['page_index'];

ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  // Show a "go down" link?
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  if (!empty($modSettings['topbottomEnable']))
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo $context['menu_separator'], '<a href="#bot">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/go_down.gif" alt="' . $txt['topbottom5'] . '" border="0" align="top" />' : $txt['topbottom5'], '</a>';

ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </td>

ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </tr>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </table>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </td>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </tr>
</table>

<a name="top"></a>

<table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder"><tr><tdÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  class="titlebg">Subject</td><tdÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  class="titlebg">Started By</td><tdÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  class="titlebg">Last Post</td></tr>';
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ, $what=ssi_recentTopics('8', NULL, 'array');


ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  foreach ($what as $topic)
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  {
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <tr>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <td class="windowbg" valign="middle">
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ', $topic['link'];

ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  // Is this topic new? (assuming they are logged in!)
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  if (!$topic['new'] && $context['user']['is_logged'])
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </td>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <td class="windowbg2" valign="middle" width="20%">
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ', $topic['poster']['link'], '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </td>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <td class="windowbg2" valign="middle" width="35%">';
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <span class="smalltext">
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ', $topic['time'], '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </span>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </td>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </tr>';
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  }

ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  echo '
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  </table>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <a name="lastPost"></a>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <table width="100%" cellpadding="3" cellspacing="0" border="0" class="tborder" style="margin-top: 1ex;">
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  <tr>
ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,  ÃÆ'ââ,¬Å
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 21, 2005, 01:08:07 PM
"page index" is calculated by SMF..but since you don't use SMF directly, but rather SSi..you need to do the calculating yourself. It depends upon how many posts you have fetched in the functiona and how many you like to display at one time...you would even need to transfer a variable that says "display from page 2" ( in other words skip x number of posts and then display).

I would just stick to 1 page and adjust the number "8" to your own needs.TP calculates pages for its articles and forum posts..but its perhaps difficult to transfer this approach to a block code.
Title: Re: "recent topics" in SMF style
Post by: Nokonium on August 21, 2005, 02:42:48 PM
Thanks Block

How many pages will be called by your Block code, would it only be one? Even if it was say 50 topics long?
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 21, 2005, 06:32:47 PM
If you look at the code..only 8 ? thats what you meant?
Title: Re: "recent topics" in SMF style
Post by: Nokonium on August 21, 2005, 08:19:22 PM
No, that is all the posts made on the last day before I made that database copy, it is set for 10. What I meant was, can the Recent Topics SSI paginate all the topics it finds or would it display them in one long page, if it was set to say 50?

I have now removed both page_index variables and got rid of two of the three errors. The frontblock error I have added to the 0.72b thread as that is my current version.
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 22, 2005, 01:21:12 PM
It would display them in one long line.

Recent topics only show subjects anyway, whereas "ssi_boardnews" shows posts..and thats what TP already use when showing last post from the forum - on the frontpage. TP asks a modified version of this function for the data, but calculates pagination and also add any page number needed in the querystring. Ssi_recenttopics out-of-the-box doesn not support fetching of x data from y starting point..it only fetches all, only limited by your "limit" number.
Title: Re: "recent topics" in SMF style
Post by: Ray on August 22, 2005, 04:51:51 PM
How could I make this to work in the center blocs??

http://www.rranderson.com/dvd/index.php?action=recent
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 22, 2005, 11:20:37 PM
You can't. It has its own template and fetching routine, and will not work inside another "action" - namely "action=tportal".
Title: Re: "recent topics" in SMF style
Post by: Ray on August 22, 2005, 11:50:05 PM
Ok thanks -- made a menu for it for now
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 26, 2005, 08:47:38 PM
can someone explain the code to me like I am a 4 year old so I can try and add this :uglystupid2:
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 26, 2005, 09:57:33 PM
You don't need to know how it works. All you need to do is add the code into your center block. Then it will automatically put the recent topics in your center block.

Goto TPadmin, then edit blocks. Scroll down to to center block and add a php block. Then put the code in it from here.
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 26, 2005, 10:43:57 PM
I am a DA :uglystupid2:
I have it now. Thanks for the tip !
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 26, 2005, 10:51:43 PM
 Any time m8.
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 27, 2005, 01:26:00 AM
I am still a DA
I used both codes in the code area's for the Recent topics and when I go into the forum or anywhere the topics still show ?

I will have more Q's  I am well PHP impaired :idiot2: Am I missing a setting ?
Thanks

http://www.golfdiscussions.com/smfbeta/index.php (http://www.golfdiscussions.com/smfbeta/index.php)
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 28, 2005, 07:43:23 PM
In the general settings for TPAdmin you can set it to display the front blocks (or not) when viewing the forums.
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 28, 2005, 10:18:14 PM
Quote from: IchBinÃÆ'ââ,¬Å¡ÃƒÂ¢Ã¢â,¬Å¾Ã,¢ on August 28, 2005, 07:43:23 PM
In the general settings for TPAdmin you can set it to display the front blocks (or not) when viewing the forums.
Pk I am not seeing this option ( TinyPortal v.0.6.5 beta )

Also how can you set "Number of posts to show on frontpage:" to 0 ?

Thanks

[attachment deleted by admin]
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 29, 2005, 03:25:02 AM
Where did you put the recent topics code? Into a Block?

Why would you want to set it to 0? You can just change it to display articles or single page?
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 29, 2005, 03:30:37 AM
Quote from: IchBinÃÆ'ââ,¬Å¡ÃƒÂ¢Ã¢â,¬Å¾Ã,¢ on August 29, 2005, 03:25:02 AM
Where did you put the recent topics code? Into a Block?

Why would you want to set it to 0? You can just change it to display articles or single page?
I figured out the 0 thing.
Yes into a php block and it shows in every single page
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 29, 2005, 03:49:05 AM
If I remember right TP 6.5 only has left and right blocks...? You can tell it to disable each of those while your in the forum. It shows it right in the picture you just posted.
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 29, 2005, 03:57:17 AM
Quote from: IchBinÃÆ'ââ,¬Å¡ÃƒÂ¢Ã¢â,¬Å¾Ã,¢ on August 29, 2005, 03:49:05 AM
If I remember right TP 6.5 only has left and right blocks...? You can tell it to disable each of those while your in the forum. It shows it right in the picture you just posted.
I am using 6.5 and I can use it in the sides and hide them, but it always shows in every page if I have it in a center block.

I see yours is only on the main page at http://www.tmrules.com/ and you have 7.2
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 29, 2005, 05:41:13 AM
Ah yes, I remember now that Bloc did not put in the option to hide the center blocks until a release after the one that you have.  I think you have to wait and see what Bloc has to say about this. Maybe he will be releasing an update for the beta testers.
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 29, 2005, 10:17:35 AM
i was planning to get the download manager module up and running before a release for beta-testers, but it might take longer than I figured.

So I will instead polish up a 0.7 release (with these options) and release it.
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 29, 2005, 12:40:07 PM
So I am not  :idiot2: after all :knuppel2: well some say I am  :uglystupid2:
Where can I get 7.2 ::) for testing :-X
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 29, 2005, 02:49:43 PM
Bloc has an invite only beta testing group that helps him polish it up a bit before he releases the beta to the regular beta testing group.
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 29, 2005, 03:37:01 PM
Quote from: IchBinÃÆ'ââ,¬Å¡ÃƒÂ¢Ã¢â,¬Å¾Ã,¢ on August 29, 2005, 02:49:43 PM
Bloc has an invite only beta testing group that helps him polish it up a bit before he releases the beta to the regular beta testing group.
Ok I stared at the cpanel on it last night for hours playing with it, opening the php files, etc. At least I know I am not crazy, insane maybe but not crazy
Thanks
Title: Re: "recent topics" in SMF style
Post by: ontap on September 11, 2005, 11:15:06 AM

if i use Frontpage Blocks, it will show a blank index page on other themes i use that are not for tinyportal. :(
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on September 16, 2005, 08:31:50 PM
I can use it in Frontpage blocks and it does not show up again, not to fond of the FP blocks though since I like the options of the blocks in the center.  Any way to get the code to only work on the main page and then stop showing up everytime ?
Title: Re: "recent topics" in SMF style
Post by: Ray on September 16, 2005, 08:56:52 PM
I just use the center blocks to have that effect -- see here

http://www.rranderson.com/

and it will only show  up on the main page not the forums pages -- is this what you want
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on September 16, 2005, 09:00:11 PM
Quote from: Ray on September 16, 2005, 08:56:52 PM
I just use the center blocks to have that effect -- see here

http://www.rranderson.com/

and it will only show  up on the main page not the forums pages -- is this what you want
I can not get mine to work that way, it always shows up on every page.. What am I missing ?
You have recent posts not topics..
Title: Re: "recent topics" in SMF style
Post by: Ray on September 16, 2005, 09:29:51 PM
Here are some pictures hope this will help
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on September 16, 2005, 09:31:35 PM
Thanks I will look at it later tonight, I am moving my site to a new server right now.
Title: Re: "recent topics" in SMF style
Post by: Ray on September 16, 2005, 09:34:36 PM
 ;D My pleasure
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on September 16, 2005, 10:11:47 PM
The top pic is kinda cut off I cant see much ;)
Title: Re: "recent topics" in SMF style
Post by: Ray on September 16, 2005, 10:31:19 PM
Just wated to show you that it was a setting in the center block
Title: Re: "recent topics" in SMF style
Post by: Ray on September 16, 2005, 10:37:33 PM
This better??
Title: Re: "recent topics" in SMF style
Post by: bloc on September 16, 2005, 11:31:54 PM
I think maybe setting "general settings" / "Hide center bar when in forum?" to "no" will give you what you seek? That way the centerblocks only show on frontpage(and all articles of course), but the forum is clear.
Title: Re: "recent topics" in SMF style
Post by: Ray on September 16, 2005, 11:53:52 PM
in the forum this is how it shows up

Title: Re: "recent topics" in SMF style
Post by: clemenzo on February 23, 2006, 11:49:33 PM
How can we show the recent block in the center below all the articles? Would there be a top/bottom block feature?
Title: Re: "recent topics" in SMF style
Post by: IchBin on February 24, 2006, 02:59:07 AM
Not "yet"....
Title: Re: "recent topics" in SMF style
Post by: ontap on March 01, 2006, 11:14:20 AM
when i use this recent topics block for the frontpage, error logs fills up with this error.


8: Undefined index: newtime
File: \Themes\default\TPortal.template.php (eval?)
Line: 19
Title: Re: "recent topics" in SMF style
Post by: evillair on March 02, 2006, 05:42:00 PM
You need to change $topic['newtime'] to $topic['time'] in the following section of the code.
See the red text...

// Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from',[$topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

Title: Re: "recent topics" in SMF style
Post by: ontap on March 03, 2006, 08:33:33 AM
Quote from: evillair on March 02, 2006, 05:42:00 PM
You need to change $topic['newtime'] to $topic['time'] in the following section of the code.

Thanks.... here is the new code!

global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('10', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: astpaul on March 27, 2006, 09:08:26 PM
Hi
Thanks a lot for this script.
I wanted to change it a little and put an exerpt of the message content. What is the correct parameter for $topic['???'] to get it ?
Couldn't get hold of the info.

Thanks a lot
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on March 27, 2006, 10:53:06 PM
Looks great, thanks for that!  8)
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 28, 2006, 03:53:30 AM
how about this little alteration..

Please look at the code and tell mer if I've got anything wrong.. its my first attempt at doing this.. it can be seen in action at http://ourmega.net/index.php
global $scripturl;

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';

$what=ssi_recentTopics('10', NULL, 'array');

foreach ($what as $topic)
  {
echo '<tr class="catbg3">
<td valign="middle">Subject</td>
<td valign="middle">Board</td>
<td valign="middle">Poster</td>
<td valign="middle">Time</td>
</tr>';

    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];

    // Is this topic new? (assuming they are logged in!)
       if (!$topic['new'] && $context['user']['is_logged'])


         echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

  echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';

    echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';

    if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))

    echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';

    echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
}

echo '</table>';
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on March 28, 2006, 03:55:54 AM
I got this from your link -  The page cannot be displayed.
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 28, 2006, 04:02:03 AM
arghh.. why not.. try it  www.ourmega.net
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on March 28, 2006, 06:12:18 AM
Quote from: BlueSteel on March 28, 2006, 04:02:03 AM
arghh.. why not.. try it  www.ourmega.net


I see it and like it on your site, but the code didn't work on my test site.
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 28, 2006, 06:49:17 AM
ok.. problem sorted out with my server.. try again to see it http://ourmega.net
Title: Re: "recent topics" in SMF style
Post by: Ray on March 28, 2006, 07:06:12 AM
Can not seem to get it to work also BlueSteel   :-\
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 28, 2006, 07:57:28 AM
Works for me now...
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 28, 2006, 08:12:37 AM
;) whew...

and are there any errors in my edited script above ???
what do you think of my changes ?
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 28, 2006, 09:14:45 AM
oops.. there was an error .. I've corrected it .. and also retested it by copying and pasting it into a new php block
Title: Re: "recent topics" in SMF style
Post by: Ray on March 28, 2006, 10:19:36 PM
Got it working ok but is they anyway to remove the menu ontop of each post and just have the one at the top??
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 29, 2006, 12:55:20 AM
ok.. looking into that.. prolly just placed it in the wrong spot in the code

Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 29, 2006, 01:07:56 AM
ok here it is updated and re-organised and re-formatted

It should now only display the headings once


// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';



Title: Re: "recent topics" in SMF style
Post by: Ray on March 29, 2006, 05:14:08 AM
Works perfect and I am using it -- thank you
Title: Re: "recent topics" in SMF style
Post by: astpaul on April 03, 2006, 09:32:59 AM
If someone is interested i can post the changes i had to make to the code to obtain this result (http://joyfund.info/forum/index.php) (see at the end of the page)
Title: Re: "recent topics" in SMF style
Post by: IchBin on April 03, 2006, 02:39:04 PM
That's good stuff! Post away astpaul. :)
Title: Re: "recent topics" in SMF style
Post by: astpaul on April 03, 2006, 02:47:21 PM
Quote from: IchBinâââ,¬Å¾Ã,¢ on April 03, 2006, 02:39:04 PM
That's good stuff! Post away astpaul. :)
Ok

It is a little tricky as i had to modify SSI.php in order to obtain the desired result.

So the actual block code is :
// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', array('1','2','3','4','5','6','7','8','9','10','12','13','14','16','17','15'), 'array', 500);

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
//echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'],'<br><font color="#666666" size="1">', $topic['preview'],'</font>';
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
//      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
//      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      echo '<td class="windowbg2" valign="middle">';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';


For the SSI modification, here is the file. Watch for lines beginning by //MODIF ASP
I had to create a new variable in ssi_recentTopics which states the number of characters one wants to display; modify the correspoding SQL order and variables.

And voila!

Hope it helps
Title: Re: "recent topics" in SMF style
Post by: elpvn on April 09, 2006, 06:32:44 PM
Thank, that's so fine in some case  :)
Title: Re: "recent topics" in SMF style
Post by: technodragon73 on April 12, 2006, 05:43:02 PM
Ok...how can i fix this?  I keep getting a error from this in the log stating newtime is an undefined index...also db.

What do i need to change in order to stop the errors?
Title: Re: "recent topics" in SMF style
Post by: jpark on April 13, 2006, 06:54:06 PM
I'm having some trouble with the array function [example - array('3','36')]  I want to list recent topics from a specific board but I am finding that it doesn't just call from the board that i indicated but others as well.  I modified bloc's code to have two columns both 42% of the screen that each call 5 recent topics from separate boards with the board titles indicated.. but i'm having that problem that i stated above.  Does anyone know how to fix this?

global $scripturl;

echo '
<table border="0" width="100%" cellspacing="1" cellpadding="2">
<tr>
<td width="42%">
<table width="100%">News</br><div class="hr"><hr /></div>
                               ';
       $what=ssi_recentTopics('5', array('9') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td width="70%" valign="top">
<img src="', $settings['images_url'], '/icons/arrow.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: left;" / >   

                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>             
                                        <td width="30%" align="center" valign="top">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>
</td>

<td width="42%">
<table width="100%">General Discussion</br><div class="hr"><hr /></div>
                               ';
       $what=ssi_recentTopics('5', array('1') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td width="70%" valign="top">
<img src="', $settings['images_url'], '/icons/arrow.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: left;" / >   

                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>             
                                        <td width="30%" align="center" valign="top">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>
</td>
</tr></table>';
Title: Re: "recent topics" in SMF style
Post by: astpaul on April 13, 2006, 07:00:17 PM
you put in the array the boards that you DO NOT want to be displayed!!! :)
Title: Re: "recent topics" in SMF style
Post by: jpark on April 14, 2006, 02:06:09 AM
ahh i see.. thanks, i will try that out
Title: Re: "recent topics" in SMF style
Post by: jpark on April 15, 2006, 09:11:35 PM
one more question.. how do i define the max length of a topic title so it fits on one line in the above code (42% of the screen)
Title: Re: "recent topics" in SMF style
Post by: astpaul on April 16, 2006, 10:49:24 AM
Quote from: jpark on April 15, 2006, 09:11:35 PM
one more question.. how do i define the max length of a topic title so it fits on one line in the above code (42% of the screen)
You can't the way you want it.
The only thing you can do is to limit your title to a specific number of characters like this:
substr($topic['topic'],0,34)
In this case, we took the 1st 34 characters.
Title: Re: "recent topics" in SMF style
Post by: technodragon73 on April 20, 2006, 06:37:05 AM
Quote from: technodragon73 on April 12, 2006, 05:43:02 PM
Ok...how can i fix this?  I keep getting a error from this in the log stating newtime is an undefined index...also db.

What do i need to change in order to stop the errors?

Anyone?
Title: Re: "recent topics" in SMF style
Post by: bloc on April 20, 2006, 12:07:52 PM
Technodragon73, try to find the ['newtime'] in the code, and exchange it with ['new_from'].
Title: Re: "recent topics" in SMF style
Post by: technodragon73 on April 20, 2006, 02:52:09 PM
Quote from: Bloc on April 20, 2006, 12:07:52 PM
Technodragon73, try to find the ['newtime'] in the code, and exchange it with ['new_from'].

That fixed it...thank you!
Title: Re: "recent topics" in SMF style
Post by: akulion on April 30, 2006, 11:21:35 AM
Quote from: BlueSteel on March 29, 2006, 01:07:56 AM
ok here it is updated and re-organised and re-formatted

It should now only display the headings once


// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';





bluesteel THANK YOU SO MUCH I have been dying for this snippet of code for ages!

UR THE BOMB!
Title: Re: "recent topics" in SMF style
Post by: deniz on April 30, 2006, 12:41:22 PM
recenttopics shows about 30-40 last topics..

why ?
how can topics count increase. ?
i need according to time.. like last day, last week, last month etc. is it possible ?

Title: Re: "recent topics" in SMF style
Post by: bloc on April 30, 2006, 01:24:47 PM
Recent topics always count from the very latest post and backwards. To set a date/timespan would mean to have to adjust the routine somewhat.

Maybe something for an "archive" sort of mod/function for posts/topics?
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on May 01, 2006, 05:40:46 AM
What you could do is change the number of msgs to be in the fetching array to a larger number and then scan for those msgs by date... and only pirint out those ones.. that makes for a way more complicate block of code .. but honestly you can do anything you want if you know how (which i don't .. I just tweak others code.. i'm not smart enough to write it out fully by myself)
Title: Re: "recent topics" in SMF style
Post by: akulion on May 01, 2006, 09:57:26 AM
i was wondering is it possible to have a modification of this code so that it does the following?

1 - Only displays topics from a particular board
2 - ONLY displays new topics (from the selected board) IF they are new topics (dosent loop topics on replies)

I ask cos I am making a "in the news" board in which I and members will post the daily news from around the world and it would appear on the TP index.

Thanks
Title: Re: "recent topics" in SMF style
Post by: bloc on May 01, 2006, 03:01:41 PM
Both thinsg could be done in the actual mysql_call. It means a custom ssi_recentTopics function though.

akulion: for just one baord is easy, but the other item I am not exactly sure what you mean.."new topics" as in unread? or as in newer than a set timespan?
Title: Re: "recent topics" in SMF style
Post by: akulion on May 01, 2006, 04:03:51 PM
by new topics I mean: A topic which has been posted just recently in that board, but replying to that post does not bring it to top on the "recent post block"

So basically ONLY when the topic is initially posted it appears in the block - but afterwards no matter how many replies it gets it dosent appear there - but can only be overtaken by newer posts/threads made
Title: Re: "recent topics" in SMF style
Post by: bloc on May 01, 2006, 06:34:27 PM
I see. So just sorting on created dates then, not on last replied date. That would mean even a simpler sql call.
Title: Re: "recent topics" in SMF style
Post by: akulion on May 01, 2006, 07:02:59 PM
Yup :D

So what do I need to do? :D:D
Title: Re: "recent topics" in SMF style
Post by: nite0859 on May 06, 2006, 07:10:26 AM
Quote from: akulion on April 30, 2006, 11:21:35 AM
Quote from: BlueSteel on March 29, 2006, 01:07:56 AM
ok here it is updated and re-organised and re-formatted

It should now only display the headings once


// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';





bluesteel THANK YOU SO MUCH I have been dying for this snippet of code for ages!

UR THE BOMB!


Beautiful. Thanks!
Title: Re: "recent topics" in SMF style
Post by: cygy2k on May 10, 2006, 01:49:51 AM
So how can you add a scroll bar and fixed height to this?
Title: Re: "recent topics" in SMF style
Post by: G6Cad on May 10, 2006, 09:17:53 AM
Read through the thread before asking. All the answers are in this thread for you to read
Title: Re: "recent topics" in SMF style
Post by: cygy2k on May 10, 2006, 03:12:47 PM
I read every word of the thread before posting, I always do.  I've seen how to make it so it auto scrolls but not to where you can have a scroll bar.  I have not seen that in any of the threads I found when searching.  I really like the new layout of this design but don't see hot to add a scroll bar.
Title: Re: "recent topics" in SMF style
Post by: johanlm on May 10, 2006, 05:49:27 PM
Redid this one a bit layoutwise so it would more look like the TP recent topics block.

Wanted it basicly to look the same, but with the option to hide rooms so I could make severall.
Thank you very much Bloc for the base code. I basiclly just rearranged, removed and added some comments so one would see directly in the code how to hide rooms etc.

global $scripturl; echo '

<table border="0" width="100%" cellspacing="1" cellpadding="2" class="bordercolor"> ';

// To show more posts change the number at recentTopics('8', to the amount you want.

// To hide specific rooms from the PHPscript replace the """, NULL,""" with """, array('7','56'),""" as an example.
// The numbers at the array = the rooms ID number. To find out what ID number the room you want to hide is, just klick on it.
// Then see what number it is at the end of the url. For example: /index.php?board=7.0 is the same as number 7

//This is the codeline you alter to change the amount of topics to show + hide rooms.
$what=ssi_recentTopics('10', NULL, 'array');

foreach ($what as $topic){echo '

<tr>
<td class="windowbg" valign="middle">

<span class="smalltext">', $topic['link'];

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged']) echo '
<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

echo '
<br>
<span class="smalltext"> ', $topic['time'],'
<br>
Poster: ', $topic['poster']['link'], '
</span>
</span>
</td>
</tr>
';}echo '
</table>
';
Title: Re: "recent topics" in SMF style
Post by: cygy2k on May 11, 2006, 02:07:50 PM
G6 or anybody else-

Any ideas on how to make a scroll bar in the new design of this?
Title: Re: "recent topics" in SMF style
Post by: G6Cad on May 11, 2006, 02:59:02 PM
Read this

http://www.dyn-web.com/dhtml/scroll/

Or this one for generate costume made with colors and 3d effects

http://www.htmlbasix.com/scrollbargenerator.shtml
Title: Re: "recent topics" in SMF style
Post by: cygy2k on May 11, 2006, 03:21:47 PM
Isn't there a way to do it with just setting the height limit of the recent topics and by putting a call for auto wrap or something?  I saw it in a different design for the layout but can't figure out how to make it happen in the new design that is really great by the way.  Sorry for my stupid sounding questions.  I'm new to PHP and really like TP.
Title: Re: "recent topics" in SMF style
Post by: bloc on May 11, 2006, 11:49:11 PM
If you put the html code inside a div with some styling like this:

<div style="height: xxpx; overflow: auto;">

..it should show scrollbars when content is larger than set height, at least in Firefox. For IE you might need some tweaking.
Title: Re: "recent topics" in SMF style
Post by: cygy2k on May 12, 2006, 12:08:12 AM
Thank you bloc.  I knew it was an easy question for you pros.  Thanks for the great product and support!!
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on May 12, 2006, 03:46:35 PM
How hard would it be to add a 'Replies' and 'Views' column in-between 'Poster' and 'Time'

Replies would be just the number of replies to that thread vs. how many views up to that point?
Title: Re: "recent topics" in SMF style
Post by: Sakuragi on May 14, 2006, 01:12:44 AM
Quote from: akulion on May 01, 2006, 09:57:26 AM
i was wondering is it possible to have a modification of this code so that it does the following?

1 - Only displays topics from a particular board
Quote from: Bloc on May 01, 2006, 03:01:41 PM
akulion: for just one baord is easy

any other way to do this instead using array('3','56') cause i have more than 80 boards and it makes my site buggy
Title: Re: "recent topics" in SMF style
Post by: jpark on May 18, 2006, 12:23:29 AM
Quote from: Bloc on May 01, 2006, 06:34:27 PM
I see. So just sorting on created dates then, not on last replied date. That would mean even a simpler sql call.

I don't know if Akulion got an answer to this but I would like to know how to do this as well.. sorry to bump and thanks in advance!  ;D
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on May 19, 2006, 12:40:56 AM
Quote from: RoarinRow on May 12, 2006, 03:46:35 PM
How hard would it be to add a 'Replies' and 'Views' column in-between 'Poster' and 'Time'

Replies would be just the number of replies to that thread vs. how many views up to that point?

Bump.  Still seeing if someone could please add the code to add 'Replies' and 'Views' column just like SMF.  See attached.  It helps our power posters.   :)
Title: Re: "recent topics" in SMF style
Post by: bloc on May 19, 2006, 01:41:30 PM
Uhm..I can help there, but what "version" are you using? The original have had a few changes by several people in this topic, so I am not sure what you are using now. :)
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on May 19, 2006, 06:37:14 PM
Quote from: Bloc on May 19, 2006, 01:41:30 PM
Uhm..I can help there, but what "version" are you using? The original have had a few changes by several people in this topic, so I am not sure what you are using now. :)

This is the version I'm using now

// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('35', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';
Title: Re: "recent topics" in SMF style
Post by: bloc on May 19, 2006, 07:33:37 PM
uhm, one problem: the SSI function doesn't collect those variables. Need to rewrite that function then.
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on May 19, 2006, 07:49:22 PM
Quote from: Bloc on May 19, 2006, 07:33:37 PM
uhm, one problem: the SSI function doesn't collect those variables. Need to rewrite that function then.

Doh!  o.k. thank Bloc   :o  no worries then.  It was a nice to have.
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on June 01, 2006, 03:24:56 AM
Quote from: RoarinRow on May 19, 2006, 06:37:14 PM
Quote from: Bloc on May 19, 2006, 01:41:30 PM
Uhm..I can help there, but what "version" are you using? The original have had a few changes by several people in this topic, so I am not sure what you are using now. :)

This is the version I'm using now

// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('35', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';


Anyone know why the number of recent topics don't show 35 like I have configured in this section of the code above:

$what=ssi_recentTopics('35', NULL, 'array'); 

Right now it shows 24 posts instead of the 35 I'd like to see.
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on June 01, 2006, 01:41:55 PM
could it be in the settings for SMF's recent topics  its self thats lower than the settings in your block ??? just guessing
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on June 02, 2006, 03:50:36 AM
Quote from: BlueSteel on June 01, 2006, 01:41:55 PM
could it be in the settings for SMF's recent topics  its self thats lower than the settings in your block ??? just guessing


Thanks, but that didn't do it  :o
Title: Re: "recent topics" in SMF style
Post by: jcortina on June 02, 2006, 03:40:31 PM
I'm pretty sure that The RecentTopics function in SSI only searches for topics within the last X number of posts (where X is a function of the number of topics requested; something like 20 or 25 times that number; uses a WHERE clause like msg_id > (last_msg - X) ).

So (assuming 25 is the number used) asking for 35 topics will return up to 35 topics which were found in the last 875 (25x35) posts. It won't keep seeking backwards until 35 are found to return.
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on June 02, 2006, 06:21:46 PM
Quote from: jcortina on June 02, 2006, 03:40:31 PM
I'm pretty sure that The RecentTopics function in SSI only searches for topics within the last X number of posts (where X is a function of the number of topics requested; something like 20 or 25 times that number; uses a WHERE clause like msg_id > (last_msg - X) ).

So (assuming 25 is the number used) asking for 35 topics will return up to 35 topics which were found in the last 875 (25x35) posts. It won't keep seeking backwards until 35 are found to return.

Ah ok. that explains it, thank you!
Title: Re: "recent topics" in SMF style
Post by: deniz on June 16, 2006, 10:10:19 AM
is it possible to show limited characters in subject field.

for example original subject: "is it possible to show limited characters in subject field"

limited characters in subject: "is it possible to show limi..."

thx.
Title: Re: "recent topics" in SMF style
Post by: jcortina on June 16, 2006, 04:17:19 PM
Instead of using $topic['subject'] in the code given, use $topic['short_subject'].

That's a shortened version of only 25 characters (not sure right now if that's 25 with or without the ellipsis '...').

Title: Re: "recent topics" in SMF style
Post by: deniz on June 16, 2006, 05:43:40 PM
there is no "$topic['subject']" in script ???
Title: Re: "recent topics" in SMF style
Post by: jcortina on June 16, 2006, 06:15:13 PM
Sorry. $topic['link'] has the full length subject embedded in it. It is this line:



    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];



Try replacing that with:



    echo '<tr><td class="windowbg" valign="middle"><a href="' . $topic['href'] . '">' . $topic['short_subject'] . '</a>';

Title: Re: "recent topics" in SMF style
Post by: RoarinRow on July 19, 2006, 05:01:00 AM
Is it possible to make the Recent Topics view similar to the Unread Topics view. 

I would really like the 'Replies' and 'Views' columns in-between the 'Poster' and 'Time' columns.
Title: Re: "recent topics" in SMF style
Post by: Techdomain on July 19, 2006, 06:31:40 AM
try adding:


<td class="windowbg2" valign="middle" width="10%">
                                                ', $topic['replies']['link'], '
                                        </td>
<td class="windowbg2" valign="middle" width="10%">
                                                ', $topic['views']['link'], '
                                        </td>

in there. you may have to fiddle with the percents, and possibly find out what the function calls for replies and views actually are (though logic tells me they would be called just that)
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on July 19, 2006, 06:34:52 AM
Quote from: Techdomain on July 19, 2006, 06:31:40 AM
try adding:


<td class="windowbg2" valign="middle" width="10%">
                                                ', $topic['replies']['link'], '
                                        </td>
<td class="windowbg2" valign="middle" width="10%">
                                                ', $topic['views']['link'], '
                                        </td>

in there. you may have to fiddle with the percents, and possibly find out what the function calls for replies and views actually are (though logic tells me they would be called just that)

I'll give it a try, thanks!
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on July 19, 2006, 07:04:02 AM
That didn't work unfortunately.  But I took what I had and put in your recommendations.  Anyone know how I can make this work?

// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('35', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3">
      <td valign="middle">Subject</td>
      <td valign="middle">Board</td>
      <td valign="middle">Poster</td>
      <td valign="middle">Replies</td>
      <td valign="middle">Views</td>
      <td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td>;
      echo '</td><td class="windowbg2" valign="middle" >', $topic['replies']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['views']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';



This is what I have right now:

// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('25', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';
Title: Re: "recent topics" in SMF style
Post by: k_4_kelly on July 24, 2006, 11:47:11 AM
Very nice code!  :up:

however, could you please tell me how could I move 'recent topics' block below the articles?   Just like this:
http://www.samsungcommunity.net/index.php?PHPSESSID=5231c4aa4ad86fbc587e9dd3d108019a;

thanks x 10000000 :)
Title: Re: "recent topics" in SMF style
Post by: akulion on July 24, 2006, 11:56:55 AM
create a PHP Center block under your TP admin 'Block Settings"

And then simply position it below the articles using the position boxes
Title: Re: "recent topics" in SMF style
Post by: Techdomain on July 24, 2006, 12:04:38 PM
position boxes?
Title: Re: "recent topics" in SMF style
Post by: akulion on July 24, 2006, 12:07:53 PM
u mean u dont have those with the cool flashing ajax java and flashing lights?

lol

I meant those little boxes in which you put the number for where to display a particular block

But I got mixed up with articles and blocks there ... sorry about that

Title: Re: "recent topics" in SMF style
Post by: Techdomain on July 24, 2006, 12:17:02 PM
ah... ok. thought there was something I was missing!
Title: Re: "recent topics" in SMF style
Post by: k_4_kelly on July 24, 2006, 01:22:50 PM
there's no an option for show 'Both Articles and Frontpage Blocks' in the general setting/frontpage/What to show on frontpage panel.

currently, my 'recent topics' block is in a PHP centre block, and it appear above the articles in the frontpage, i would like to move it under the articles not above. :(

Could anyone tell me how to do it?

thanks!!!!
Title: Re: "recent topics" in SMF style
Post by: technodragon73 on July 24, 2006, 01:38:28 PM
I believe that option is what is in the next release of TP...you'll just have to wait.
Title: Re: "recent topics" in SMF style
Post by: k_4_kelly on July 24, 2006, 03:11:01 PM
hello..
thanks for your reply
do you have any idea about how could this person able to move the 'recent topic' block under the articles?

http://www.samsungcommunity.net/index.php?PHPSESSID=5231c4aa4ad86fbc587e9dd3d108019a;

thanks!
Title: Re: "recent topics" in SMF style
Post by: Max on July 24, 2006, 03:15:56 PM
this is buggin me a small big....
tryin to get the group colour to show on the posters name (if there in a group)

does anyone have an idea on how to add it to this big of code?

global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('10', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


i know its something like "$topic['poster']['onlineColor']['link']" but im missing something else  :-\

Screenshot:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg208.imageshack.us%2Fimg208%2F3889%2Ftutorial4pw3.jpg&hash=37986c6b80344f936f817b1909ff8dade7a553ae)
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 03, 2006, 07:52:11 PM
Quote from: jcortina on June 02, 2006, 03:40:31 PM
I'm pretty sure that The RecentTopics function in SSI only searches for topics within the last X number of posts (where X is a function of the number of topics requested; something like 20 or 25 times that number; uses a WHERE clause like msg_id > (last_msg - X) ).

So (assuming 25 is the number used) asking for 35 topics will return up to 35 topics which were found in the last 875 (25x35) posts. It won't keep seeking backwards until 35 are found to return.

That worked!  Thank you very much.   :up:
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 03, 2006, 09:22:57 PM
Quote from: RoarinRow on July 19, 2006, 05:01:00 AM
Is it possible to make the Recent Topics view similar to the Unread Topics view. 

I would really like the 'Replies' and 'Views' columns in-between the 'Poster' and 'Time' columns.

Now is someone knew how I can make the 'Recent Topics' look like the 'Unread Topics' view, I'd be set.   :uglystupid2:
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 05, 2006, 10:41:46 PM
Quote from: RoarinRow on August 03, 2006, 09:22:57 PM
Now is someone knew how I can make the 'Recent Topics' look like the 'Unread Topics' view, I'd be set.   :uglystupid2:

Recent Topics Block - Unread Topics View

phpbox - center block - do not use title/frame

Sorts by most recent on top (can't click headings to sort differently)

Uses setting for number of recent posts to display on board index number
(this code could be put in boardindex.template to replace most recent posts
with this format of most recent topics).

Can be used in php article with $num_to_return set to a number like 50
to give longer list of most recent topics (read or unread).



global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings;

  if (!empty($settings['number_recent_posts']))
    {
$num_to_return = $settings['number_recent_posts'];

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
    WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_to_return, 5)) . "
    AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
ORDER BY t.ID_LAST_MSG DESC
            LIMIT " . $num_to_return, __FILE__, __LINE__);


$topics = array();
$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'ÂÃ,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ÂÃ,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . $row['firstPosterName'] . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . $row['lastPosterName'] . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', "Most Recently Posted to Topics", '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
}

Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 05, 2006, 11:13:42 PM
Great, thank you very much, this is exactly what I'm looking as far as the format and layout, just like 'Unread topics'.

One thing, when I try to change the $num_to_return to 50, it only displays the number of posts from the Current Theme setting, which I have set at 15. 

Anyway to fix that?  Please.

This is the section I changed to 50

WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 50 * min($num_to_return, 5)) . "
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 05, 2006, 11:17:57 PM
No, you do that up at the 3rd line of the code:

$num_to_return = $settings['number_recent_posts'];

to

$num_to_return = 50;
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 05, 2006, 11:23:39 PM
Quote from: jacortina on August 05, 2006, 11:17:57 PM
No, you do that up at the 3rd line of the code:

$num_to_return = $settings['number_recent_posts'];

to

$num_to_return = 50;


Doh!  That's the ticket!   :uglystupid2:  You're awesome!
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 06, 2006, 04:58:32 PM
This is a much more versatile version of it (to use as article).

This will give most recent XX posted to topics -OR-
most recent XX unreplied to topics -OR-
topics posted to in last XX hours

All in the detailed topic format

Default
index.php?page=##
most recent posted to topics - will list
number equal to  $settings['number_recent_posts']

index.php?page=##;count=50 or index.php?page=##;type=last;count=50
50 most recently posted to topics

index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
Most recent unreplied to topics - will
list number specified in 'count' or default to
number equal to  $settings['number_recent_posts']

index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
Topics posted to in last number of hours
specified in 'count' or default to 24.



global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings;

if (empty($settings['number_recent_posts']))
$number_recent_posts = 15;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
    WHERE " . $where_clause . "
    AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
ORDER BY t.ID_LAST_MSG DESC " . $limit_clause, __FILE__, __LINE__);


$topics = array();
$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'ÂÃ,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ÂÃ,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . $row['firstPosterName'] . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . $row['lastPosterName'] . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }

Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 07, 2006, 10:39:41 PM
Wow jacortina, this just got better.  For the longest time I've wanted the 'last 24 hour' option.  You rock, thank!    :up:

One question just on the layout.  Is it possible to put the board name underneath the thread title? 

Right now it shows for example, Doug's new car in Hot Cars, all in a straight line.

Is possible to make it so it shows:

Doug's new car
in Hot Cars

Thanks!
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 08, 2006, 12:19:04 AM
No problem (what was given was just the same format as used
in the Unread since Last).

Find:

<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>


Change to:

<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>

Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 08, 2006, 12:28:41 AM
Quote from: jacortina on August 08, 2006, 12:19:04 AM
No problem (what was given was just the same format as used
in the Unread since Last).

Find:

<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>


Change to:

<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>



That's the ticket!  Thank you!!   :D
Title: Re: "recent topics" in SMF style
Post by: rbh on August 08, 2006, 05:37:30 AM
jacortina, very much improved upon! one thing, how do i get it to use the same colors as what my forum uses? where it says subject, started by, etc etc, it should be same as within forums but it isn't.
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 08, 2006, 05:49:40 AM
One last question jacortina, where can I make the same change of the hard return to the 'All unread topics'?  This way both my views will be consistent.
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 08, 2006, 07:00:22 PM
Quote from: rbh on August 08, 2006, 05:37:30 AM
jacortina, very much improved upon! one thing, how do i get it to use the same colors as what my forum uses? where it says subject, started by, etc etc, it should be same as within forums but it isn't.

As this code is based on that used for Unread Replies (Recent and All), it only does what that does. The query used there (and here) doesn't get/apply the group colors (doesn't query the membergroup table at all).


Quote from: RoarinRow on August 08, 2006, 05:49:40 AM
One last question jacortina, where can I make the same change of the hard return to the 'All unread topics'?  This way both my views will be consistent.

Recent.template.php

It will change both All Unread and Recent Unread.

Find:
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>

Change to:
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>

$txt['smf88'] is the word 'in' -> "in [BoardName]"

If you want to change how Unread Replies are presented also...

Find:
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '
', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>



Change to:
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '<br>',
$txt['smf88'], ' ', $topic['board']['link'], '</span></td>


(The < br > is put at the end of the first of these lines)
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 08, 2006, 10:38:05 PM
Quote from: jacortina on August 08, 2006, 07:00:22 PM
Quote from: rbh on August 08, 2006, 05:37:30 AM
jacortina, very much improved upon! one thing, how do i get it to use the same colors as what my forum uses? where it says subject, started by, etc etc, it should be same as within forums but it isn't.

As this code is based on that used for Unread Replies (Recent and All), it only does what that does. The query used there (and here) doesn't get/apply the group colors (doesn't query the membergroup table at all).


Quote from: RoarinRow on August 08, 2006, 05:49:40 AM
One last question jacortina, where can I make the same change of the hard return to the 'All unread topics'?  This way both my views will be consistent.

Recent.template.php

It will change both All Unread and Recent Unread.

Find:
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>

Change to:
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>

$txt['smf88'] is the word 'in' -> "in [BoardName]"

If you want to change how Unread Replies are presented also...

Find:
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '
', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>



Change to:
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '<br>',
$txt['smf88'], ' ', $topic['board']['link'], '</span></td>


(The < br > is put at the end of the first of these lines)

Thank you again jacortina!  The first part of the code for All unread topics works perfectly.  The second part but the board name below the topic name, but the topic name is not a URL.  I tried to redo the find and replace several times and I'm sure that's still my problem. 

Can you please look at that last part when you are available?   ::)
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 09, 2006, 01:52:26 AM
Could you supply a few lines of code around those lines from your file?
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 09, 2006, 02:17:34 AM
Quote from: jacortina on August 09, 2006, 01:52:26 AM
Could you supply a few lines of code around those lines from your file?

Hi, thanks.  In fact, here's the whole file attached.   :uglystupid2:
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 09, 2006, 03:43:35 AM
Just to confirm, the problem you experienced was with
Unread Replies, right?

If so, try -

Starting in Line 286:

Find:

<td class="windowbg', $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">
' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , '
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '
', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>


Replace with:

<td class="windowbg', $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">
' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , '
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '<br>',
$txt['smf88'], ' ', $topic['board']['link'], '</span></td>
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 09, 2006, 04:36:47 AM
Quote from: jacortina on August 09, 2006, 03:43:35 AM
Just to confirm, the problem you experienced was with
Unread Replies, right?

If so, try -

Starting in Line 286:

Find:

<td class="windowbg', $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">
' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , '
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '
', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>


Replace with:

<td class="windowbg', $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">
' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , '
' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', ' ', $topic['first_post']['link'], ' <a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a> <span class="smalltext">', $topic['pages'], '<br>',
$txt['smf88'], ' ', $topic['board']['link'], '</span></td>


Yes it is with 'unreadreplies'.  This new code clear up the link, but the board name is still in the same line 
Title: Re: "recent topics" in SMF style
Post by: oneway on August 09, 2006, 02:14:38 PM
SHOW THE POSTER IN RECENT TOPICS?

What I would like with RC2 and 0.86 seems simple: it's just to show the poster in Recent Posts. It seems a major lack only having topic and date, but not 'who'.

Looks to me like 0.95 may have it, but I don't have this version, so could someone tell me how can I get it in 0.86? (I can see code in php files like, all ready to do it! - but I do not have the expertise to implement).

Thanks for the help and support given here!
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 09, 2006, 11:12:29 PM
Quote from: RoarinRow on August 09, 2006, 04:36:47 AM
Yes it is with 'unreadreplies'.  This new code clear up the link, but the board name is still in the same line

Well, the second to the last line of that code ends:


$topic['pages'], '<br>',


Which means there's a line break after the pages (or
the blank where page numbers would be).

I suppose you could try to change it to

$topic['pages'], '<br />',

for the proper form and see if that helps.
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on August 09, 2006, 11:32:39 PM
Quote from: jacortina on August 09, 2006, 11:12:29 PM
Quote from: RoarinRow on August 09, 2006, 04:36:47 AM
Yes it is with 'unreadreplies'.  This new code clear up the link, but the board name is still in the same line

Well, the second to the last line of that code ends:


$topic['pages'], '<br>',


Which means there's a line break after the pages (or
the blank where page numbers would be).

I suppose you could try to change it to

$topic['pages'], '<br />',

for the proper form and see if that helps.

Thank you, I found the problem.  It was 'user issue'  I had a couple of versions while I was testing, I guess I uploaded the wrong version.

All is well, thanks again.   :up:
Title: Re: "recent topics" in SMF style
Post by: akulion on August 19, 2006, 08:28:31 PM
any idea how i can get the topic to be sorted on 'creation date' as opposed to 'reply date' ?

What I want to achieve is that the topic does not get bumped up if someone replies to it...but can only be over taken by newer threads which are started
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 19, 2006, 11:56:42 PM
Quote from: akulion on August 19, 2006, 08:28:31 PM
any idea how i can get the topic to be sorted on 'creation date' as opposed to 'reply date' ?

What I want to achieve is that the topic does not get bumped up if someone replies to it...but can only be over taken by newer threads which are started

If using the code that I posted earlier in this thread in message:
http://www.tinyportal.net/smf/index.php?topic=596.msg58157#msg58157

You'd simply change the line:

ORDER BY t.ID_LAST_MSG DESC " . $limit_clause, __FILE__, __LINE__);


To:

ORDER BY t.ID_FIRST_MSG DESC " . $limit_clause, __FILE__, __LINE__);


Since first message ID order is in direct relation to message creation order.

While the code given is set up to present the options listed in that message, this code can be easily adapted to pull a list of topics ( t.ID_TOPIC IN (" . implode(', ', <array of topic numbers>) . ") ) or all topics in a board (t.ID_BOARD = <board number>).

Also, while this is set up to output in the style of Unread topics, the code can be changed to format the output as desired. The point of this is that the query supplies the information that it does.
Title: Re: "recent topics" in SMF style
Post by: mr juntao on September 14, 2006, 01:58:15 AM
I thought it best to ressurect this topic than start a new one :)

But basically how could you do it so that if there were any unread posts/topics they would have a different colour background rather than the "new" image.
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 14, 2006, 02:09:55 AM
Personally, I'd add new classes to the style.css for windowbgunread and windowbg2unread (use windowbg and windowbg2 as guides) and then use variables for the ones to use in the code given ($usebg is windowbg or windowbgunread; $usebg2 is windowbg2 or windowbg2unread).

But then, personally, I'd never get rid of the 'new' image. It's not just a graphic, it's a link to the  first unread messgage in the topic. Why make things LESS navigable?
Title: Re: "recent topics" in SMF style
Post by: mr juntao on September 14, 2006, 02:20:39 AM
Theres a link on the right anyway to the latest post so i do not see the need for it. The colour helps differentiate to the user alot quicker which threads need reading or have been missed. Ill try and see if i can manage to put something together the way you mentioned although i will probably fail  :(

thanks for the suggestion  :up:
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 14, 2006, 02:40:38 AM
Thats the last post, not the first unread. You're going to tell them with the background that there are new posts but take away the link to the first of the new posts. You could still give it a different background color and keep the functionality.

Just find the occurences of the windowbg and windowbg2 entries in the style sheet. Copy them, name the copies to the 'unread' versions, and give them the new background colors you want.

If you're basing this on the code from:
http://www.tinyportal.net/smf/index.php?topic=596.msg58157#msg58157

Then once you have the css in place,

Find:

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';


And replace with:

if ($topic['new'] == 0)
{
$usebg = windowbgunread;
$usebg2 = windowbg2unread;
}
else
{
$usebg = windowbg;
$usebg2 = windowbg2;
}

echo '
<tr>
<td class="'.$usebg2.'" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="'.$usebg2.'" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="'.$usebg2.'" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="'.$usebg.'" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="'.$usebg.'" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="'.$usebg2.'" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';


And this DOES leave the 'new' icon in place.
Title: Re: "recent topics" in SMF style
Post by: mr juntao on September 16, 2006, 04:42:36 PM
Thanks alot that code is amazing, it also added the icons to the left which is what i wanted aswell :)

I modified it so that it didnt look too cluttered and only had the info i wanted it too, but thanks alot, you can see it at www.ps360.org

Thanks  :up:
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 27, 2006, 02:54:03 AM
OK. I just couldn't leave well enough alone.

Now has member color links. And can list most recently posted to 'watched' topics (topics in your notify list). And can sort by topic start (creation) date.

See code for usage. Previous parameters unchanged, so should be fine to drop into place (to enable member colors).


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block)
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert these lines and those below next section
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'ÂÃ,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ÂÃ,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

        $dummy = array();
        $dummy[] = $row['ID_FIRST_MEMBER'];
        $dummy[] = $row['ID_LAST_MEMBER'];
        loadMemberData($dummy);
        $profile_first = &$user_profile[$row['ID_FIRST_MEMBER']];
        $profile_last = &$user_profile[$row['ID_LAST_MEMBER']];

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $profile_first['member_group_color'] . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $profile_last['member_group_color'] . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:-4px;"' : 'style="margin:-4px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


Screenshot:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg208.imageshack.us%2Fimg208%2F6262%2Ftutorial3lh0.jpg&hash=f395174f5c8a1b48d7820258e64feb673a7e9db3)
Title: Re: "recent topics" in SMF style
Post by: stormlrd on September 27, 2006, 03:00:04 AM
Neat I'll have to look at i later when Im not so coded out lol
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on September 27, 2006, 05:00:40 AM
Wow, it gets better and better   :up:
Title: Re: "recent topics" in SMF style
Post by: akulion on September 27, 2006, 07:54:19 AM
 O0 :up:

gomobo gomobo gomobo gomobo

la la lu lu pom pom pupu

O0 :up:
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 27, 2006, 02:14:14 PM
Quote from: akulion on September 27, 2006, 07:54:19 AM
O0 :up:

gomobo gomobo gomobo gomobo

la la lu lu pom pom pupu

O0 :up:

Uh... Thanks (I think). ;)
Title: Re: "recent topics" in SMF style
Post by: akulion on September 27, 2006, 02:18:52 PM
Ur welcome...and Thanks for the bloc its great!

its a song i composed using only verbal sound effects O0 :up:
Title: Re: "recent topics" in SMF style
Post by: daftdate on September 27, 2006, 11:58:02 PM
so with the new code with looks great by the way :D how do we exclude a board such as my calendar board which i only want members to get through to from the calendar?
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 28, 2006, 12:07:45 AM
Quote from: daftdate on September 27, 2006, 11:58:02 PM
so with the new code with looks great by the way :D how do we exclude a board such as my calendar board which i only want members to get through to from the calendar?
This isn't built on any part of the SSI Recent Topics code, so that type of exclusion wasn't built in (except based on ability to see the board at all).

Give me a few and I'll fix it up.
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 28, 2006, 01:02:29 AM
Here you go. Specify board(s) to exclude. Not up for messing around trying to parse a passed in board list.


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
$exclude_boards = array(); // KEEP (to preserve variable declaration)
// $exclude_boards = array(5); //  Exclude single board
// $exclude_boards = array(5, 8); //  Exclude multiple boards
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block)
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'ÂÃ,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ÂÃ,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

        $dummy = array();
        $dummy[] = $row['ID_FIRST_MEMBER'];
        $dummy[] = $row['ID_LAST_MEMBER'];
        loadMemberData($dummy);
        $profile_first = &$user_profile[$row['ID_FIRST_MEMBER']];
        $profile_last = &$user_profile[$row['ID_LAST_MEMBER']];

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $profile_first['member_group_color'] . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $profile_last['member_group_color'] . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:-4px;"' : 'style="margin:-4px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


Screenshot:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg208.imageshack.us%2Fimg208%2F753%2Ftutorial2jm0.jpg&hash=d9069b431a9825469b7c8e03ff8c0fb264c99bd1)
Title: Re: "recent topics" in SMF style
Post by: akulion on September 28, 2006, 01:22:56 AM
thanks - very good stuff :up: top of the pops :up:
Title: Re: "recent topics" in SMF style
Post by: daftdate on September 28, 2006, 07:11:12 AM
Thats wonderful thanx  :)
Title: Re: "recent topics" in SMF style
Post by: Svaha on September 28, 2006, 10:15:13 AM
Very nice, there is one thing I don't get. I used it as a block, that is perfect. Then I made a php article (no title, no frame), and finaly a menu link like www.mysite.com/index.php?page=07, but then I get the source displayed?

Enlighten me please.
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 28, 2006, 03:46:24 PM
Are you sure it's set as php article and not html?

What source is being displayed?

Do other articles display properly when linked like that?
Title: Re: "recent topics" in SMF style
Post by: akulion on September 28, 2006, 04:21:06 PM
also try and turn the editor off if u have one enabled

in TP settings u can turn the editor off

it can cause errors with code causing the code to be displayed...

just a sugegstion
Title: Re: "recent topics" in SMF style
Post by: Svaha on September 28, 2006, 06:32:09 PM
Yes, I disabled the wysiwyg editor, choose articles/php/pasted the code and choose no title/no frame.
But this may seem strange, if I change the theme from Epsilon to default, the 'article' is displayed properly as you can see here  http://www.alohaspirit.rainbowshaman.com/index.php (scroll down a bit) the number of the article is 9.

Title: Re: "recent topics" in SMF style
Post by: jacortina on September 28, 2006, 07:11:46 PM
Well, I'm not sure where to even start analyzing that situation (I use what's basically the default theme with modified css).

But seeing it in place on your forum is makes me want to pull out the hard-coded strings and put them into variables so you can translate them more easily than having to hunt them down within the code.
Title: Re: "recent topics" in SMF style
Post by: Svaha on September 28, 2006, 08:08:02 PM
Quote from: jacortina on September 28, 2006, 07:11:46 PM
Well, I'm not sure where to even start analyzing that situation (I use what's basically the default theme with modified css).

But seeing it in place on your forum is makes me want to pull out the hard-coded strings and put them into variables so you can translate them more easily than having to hunt them down within the code.

I like your snippets and am sure my members like them too, I was thinking of building this into the member menu, then this would be the best (not to use hardcoded strings)
but now it's no big deal, to me it's no problem to translate this into dutch.
I just have to figure out why this doesn't work in the epsilon theme.
First I will try some other themes, see what they 'do'.
Thank you (and others) for your help, I appreciate this.
Title: Re: "recent topics" in SMF style
Post by: Svaha on September 28, 2006, 08:24:55 PM
Damn, lol, it works in oxygen, manuscript, default, pn-pn, mirage, but not in epsilon, and epsilon is the theme I like most, pitty but goodbye epsilon. :)
Title: Re: "recent topics" in SMF style
Post by: akulion on September 30, 2006, 08:17:47 PM
is there a way i can show only Last X topics from a specific user?

What I want to achieve is this:

User A ---> Logs in and sees:

Block: Your Last 5 topics
---> shows the last 5 topics that user CREATED and DOES NOT recycle when new replies are made, meaning topics do not get bumped up but only appear in the last 5 sequence

Block: Your Last 5 replies ( to posts)
---> shows the last 5 threads the user was active in (recently) and updates normally like "recent topics" block when new replies are made.

Possible?

Title: Re: "recent topics" in SMF style
Post by: jacortina on October 01, 2006, 12:34:04 AM
Quote from: akulion on September 30, 2006, 08:17:47 PM
is there a way i can show only Last X topics from a specific user?

What I want to achieve is this:

User A ---> Logs in and sees:

Block: Your Last 5 topics
---> shows the last 5 topics that user CREATED and DOES NOT recycle when new replies are made, meaning topics do not get bumped up but only appear in the last 5 sequence

Block: Your Last 5 replies ( to posts)
---> shows the last 5 threads the user was active in (recently) and updates normally like "recent topics" block when new replies are made.

Possible?

*** NOTE *** NOTE *** NOTE ****
This iteration of the code addresses the Recycle Bin and will eliminate it from results, if present.


Possible. And first part is done. The second part may take a few days to get to because it's not quite as straightforward (first and last message poster is part of the original query, but finding if current user is involved anywhere in a thread independent of whether they're being notified of it is a little different).

Anyway, using this code in a block consists of writing the variable parts of the query and the text for the block heading:

//   $heading = 'Most Recent Topics You Started';
//   $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
//   $limit_clause = 'LIMIT 5';
//   $order_clause = 't.ID_FIRST_MSG DESC';

And removing the logic to build these things from passed in parameters (which works for articles linked by page=XX, but not blocks).

This is noted in the code.


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
$exclude_boards = array(); // KEEP (to preserve variable declaration)
// $exclude_boards = array(5); //  Exclude single board
// $exclude_boards = array(5, 8); //  Exclude multiple boards
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $heading = 'Most Recent Topics You Started';
// $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
// $limit_clause = 'LIMIT 5';
// $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'ÂÃ,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ÂÃ,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

        $dummy = array();
        $dummy[] = $row['ID_FIRST_MEMBER'];
        $dummy[] = $row['ID_LAST_MEMBER'];
        loadMemberData($dummy);
        $profile_first = &$user_profile[$row['ID_FIRST_MEMBER']];
        $profile_last = &$user_profile[$row['ID_LAST_MEMBER']];

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $profile_first['member_group_color'] . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $profile_last['member_group_color'] . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';
Title: Re: "recent topics" in SMF style
Post by: akulion on October 01, 2006, 05:22:43 AM
thanks :D

i will try it out after a short break...just finished integrating coppermine into SMF/TP ..phew lol

Thanks again :D
Title: Re: "recent topics" in SMF style
Post by: rctxtreme on October 01, 2006, 05:44:56 AM
Does this block work in a side block without looking strange?
Title: Re: "recent topics" in SMF style
Post by: jacortina on October 01, 2006, 05:55:59 AM
Quote from: rctxtreme on October 01, 2006, 05:44:56 AM
Does this block work in a side block without looking strange?

No. Not as it is. You'd have to reformat the output pretty extensively. This outputs a table with rows just like 'Show Unread' or full width board display of topics. But all the info is there to change it to echo it out in whatever way you'd want to rewrite it.
Title: Re: "recent topics" in SMF style
Post by: moviespot on November 17, 2006, 11:16:35 PM
is there a block for Tinyportal ( Tinyportal Style ) for PHP Block ?

without edit for template ?
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 17, 2006, 11:39:55 PM
Quote from: moviespot on November 17, 2006, 11:16:35 PM
is there a block for Tinyportal ( Tinyportal Style ) for PHP Block ?

without edit for template ?

Not sure I know what you're asking for.

The code given can certainly work in a center php block. You have to supply any values to determine the topics to show.

Look at the code in http://www.tinyportal.net/smf/index.php?topic=596.msg75309#msg75309

The comments have examples of arguments to supply for a couple of uses.
Title: Re: "recent topics" in SMF style
Post by: moviespot on November 17, 2006, 11:51:16 PM
i don't want it on SMF style , i want it like Tinyportal style box but i need to put the code myself .. thanks.
Title: Re: "recent topics" in SMF style
Post by: Techdomain on November 17, 2006, 11:55:42 PM
I think I remember something about it being an SSI function... wouldnt know what though
Title: Re: "recent topics" in SMF style
Post by: G6Cad on November 18, 2006, 04:33:22 PM
Yes, thats what i rememberd to, And i thought it was in the snippets board. JPDeni if i remember correct made it work to  ???
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 25, 2006, 08:19:36 PM
Is that first code fromBloc under Page 1 of this thread limited to the last 25 recent postings ?
When I set more than the standard 8 entries at:
e.g.:

$what=ssi_recentTopics('99', NULL, 'array');

It only
display the recent 25 postings...
Hmm..
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 25, 2006, 09:49:19 PM
I have now integrated this code from:
http://www.tinyportal.net/smf/index.php?topic=596.msg75309#msg75309
into my frontpage.

Now I see, that when I choose in the admin panel how many
recent postings it should display in the Forum Infocenter at the bottom
of the forum, that this setting is also used for the above code...

So now when I set this to 100 recent postings on my front page,
the Infocenter box at the bottom of my forum page
will also display 100 recent postings, which I donÂÃ,´t want.

I now want only the last 100 recent postings to be displayed on the
Frontpage and not on the forum InfoCenter box...
How do I change this?

Many thanks.
Title: Re: "recent topics" in SMF style
Post by: bloc on November 25, 2006, 10:45:28 PM
Uhm..I am gonna let J.A.Cortina answer that...but it might be some shared setting that does this.
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 25, 2006, 10:49:48 PM
Quote from: Bloc on November 25, 2006, 10:45:28 PM
Uhm..I am gonna let J.A.Cortina answer that...but it might be some shared setting that does this.

I'm quite confused on what version of the code is being used.

None of the iterations of the code I've posted use the SSI functions at all, though it DOES use the forum's 'Recent Post' number as the default count to display.
Title: Re: "recent topics" in SMF style
Post by: bloc on November 25, 2006, 11:02:20 PM
I think thats the issue...that he sets that to a high number and of course it will then also show that in Info center.
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 26, 2006, 02:42:25 AM
Quote from: J.A.Cortina on November 25, 2006, 10:49:48 PM
Quote from: Bloc on November 25, 2006, 10:45:28 PM
Uhm..I am gonna let J.A.Cortina answer that...but it might be some shared setting that does this.

None of the iterations of the code I've posted use the SSI functions at all, though it DOES use the forum's 'Recent Post' number as the default count to display.

Well, yes, that is the issue.

How can I set it differently from the Info Center that means
from the setting from the admin panel ?

Maybe I can it set it directly somehow in the code ?

I want in the Info Center only about 10 recent posts and
on the Front page about 100 to 200 recent postings.

Many thanks.
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 26, 2006, 03:00:13 AM
And you said you were using code which called the SSI function.

Quote from: hartiberlin on November 25, 2006, 08:19:36 PM
$what=ssi_recentTopics('99', NULL, 'array');

As mentioned, none of the code I posted uses that. It quite specifically builds the topic array iteself and NOT by calling any SSI function.

Therefore, I'm not familiar with the code you are using.

If you were using the code I posted in http://www.tinyportal.net/smf/index.php?topic=596.msg75309#msg75309 , it would depend on how you were using it. In an article, you could include the "count=XX" in the calling URL. If using in a block, you'd supply the proper 'Limit clause' as is documented in the code block itself.
Title: Re: "recent topics" in SMF style
Post by: pvcblue on November 26, 2006, 05:18:46 AM
ok I am using this code -


global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('10', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


now the problem is - it does not mark the post/topic read. It does on the tP front page in the recent block, but not when you go back to the forum page, you see a page full of new image indicators! How do you fix this??????????
Title: Re: "recent topics" in SMF style
Post by: pvcblue on November 26, 2006, 10:21:21 PM
Quote from: pvcblue on November 26, 2006, 05:18:46 AM
ok I am using this code -


global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('10', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


now the problem is - it does not mark the post/topic read. It does on the tP front page in the recent block, but not when you go back to the forum page, you see a page full of new image indicators! How do you fix this??????????

NoOne can or knows how to fix this?
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 26, 2006, 10:34:38 PM
This piece seems to put out the 'new' image for topics which AREN'T new???

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])


Does changing it to this help?
                // Is this topic new? (assuming they are logged in!)
                if ($topic['new'] && $context['user']['is_logged'])

Title: Re: "recent topics" in SMF style
Post by: pvcblue on November 26, 2006, 11:11:12 PM
Quote from: J.A.Cortina on November 26, 2006, 10:34:38 PM
This piece seems to put out the 'new' image for topics which AREN'T new???

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Is this topic new? (assuming they are logged in!)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if (!$topic['new'] && $context['user']['is_logged'])


Does changing it to this help?
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Is this topic new? (assuming they are logged in!)
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if ($topic['new'] && $context['user']['is_logged'])



The problem is not with the block itself perse J.A. . The block "new" image dissapears after it has been read, the new image on the forum itself does not change to the read image, you have to go back to the forum itself and "mark all as read" to get the images to switch.
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 27, 2006, 04:52:08 AM
Hello,
thanks for all the updates,
but I know have an urgent problem with my hoster.

It says:
There has been a problem with the database!
MySQL reported:
User "hartiberlin" has exceeded the 'max_questions' resource (current value: 70000)

This is a notice email to let you know that SMF could not connect to the database, contact your host if this continues.


Does this Recent Topic use so many queries to the database ?

It seems, my just 39 onliline users at the moment generate
more than 70.000 queries in ONE HOUR ?!

Could this be, or is someone trying to download the whole
forum with a tool or is Google spidering the whole website ?
Title: Re: "recent topics" in SMF style
Post by: Techdomain on November 27, 2006, 01:13:23 PM
wow! that sounds like a whole new topic to me!
Title: Re: "recent topics" in SMF style
Post by: pvcblue on November 27, 2006, 03:09:07 PM
Quote from: J.A.Cortina on November 26, 2006, 10:34:38 PM
This piece seems to put out the 'new' image for topics which AREN'T new???

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])


Does changing it to this help?
                // Is this topic new? (assuming they are logged in!)
                if ($topic['new'] && $context['user']['is_logged'])



The problem is not with the block itself perse J.A. . The block "new" image dissapears after it has been read, the new image on the forum itself does not change to the read image, you have to go back to the forum itself and "mark all as read" to get the images to switch.
Title: Re: "recent topics" in SMF style
Post by: hsdk on November 27, 2006, 03:54:40 PM
Hi, i need a little bit of help. (Okey, i really need a lot of help ! :laugh: )

I use this to display my 50 most recent threads


global $scripturl;
$what=ssi_recentTopics('50', NULL, 'array');

echo '<blockquote><table border="0" width="100%" cellspacing="1" cellpadding="4" class="windowbg">';
echo '<tr class="titlebg"><td valign="middle"><b>Siste 50 innlegg fra forumet:
</b></td><td>Forum</td><td valign="middle">Forfatter</td><td>Tidspunkt</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="smalltext" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="smalltext" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="smalltext" valign="middle" >', $topic['poster']['link'], '</td><td class="smalltext" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</blockquote></table>';


Now, this is what i want to do:

1) make a similar page that shows threads from a single specific board
2) make a page that shows a user only his post from the same board

Could this be done? How? Can someone help? :)


Best Regards
Andreas
Title: Re: "recent topics" in SMF style
Post by: pvcblue on November 27, 2006, 04:27:18 PM
Quote from: hsdk on November 27, 2006, 03:54:40 PM
Hi, i need a little bit of help. (Okey, i really need a lot of help ! :laugh: )

I use this to display my 50 most recent threads


global $scripturl;
$what=ssi_recentTopics('50', NULL, 'array');

echo '<blockquote><table border="0" width="100%" cellspacing="1" cellpadding="4" class="windowbg">';
echo '<tr class="titlebg"><td valign="middle"><b>Siste 50 innlegg fra forumet:
</b></td><td>Forum</td><td valign="middle">Forfatter</td><td>Tidspunkt</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="smalltext" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="smalltext" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="smalltext" valign="middle" >', $topic['poster']['link'], '</td><td class="smalltext" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</blockquote></table>';


Now, this is what i want to do:

1) make a similar page that shows threads from a single specific board
2) make a page that shows a user only his post from the same board

Could this be done? How? Can someone help? :)


Best Regards
Andreas

this was done back near the beginning of this thread
Title: Re: "recent topics" in SMF style
Post by: hsdk on November 27, 2006, 04:42:03 PM
Quote from: pvcblue on November 27, 2006, 04:27:18 PM
this was done back near the beginning of this thread

Ups, sorry! Will look for it! Exactly this? im kind of a newbie at this php thing, so kind of need help with making the output look the same as my "recent 50" :)

Thanks!


Edit:


Okey i now have the first thing i wanted. But i have a problem

when using this:


global $scripturl;
$what=ssi_recentTopics('100',array('1','2','3','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23'), 'array');

echo '<blockquote><table border="0" width="500" cellspacing="1" cellpadding="4" class="windowbg">';
echo '<tr class="titlebg"><td valign="middle"><b>Dykkested:
</b></td><td valign="middle">Logget av:</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="smalltext" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    //echo '</td><td class="smalltext" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="smalltext" valign="middle" >', $topic['poster']['link'], '</td><td class="smalltext" valign="middle" >';

//if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] .   
// '/images/icons/last_post.gif'))
//echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" //title="', $txt[111], '" border="0" style="float: right;" /></a>';
//echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</blockquote></table>';


It just gives me the last three topics? i can set the number as high as 1000 and it still only returns 3.
An it shows a link to the newst post in the actual topic, i want a link to the first post, and i will show the name of the user that created the topic, not the name of the one with the last post. :-(

Edit2: Okey, so i figured out that this had to be changed in the recent topics function in ssi.php, so i made a copy called ssi_recentTopics2, and tried to make the changes, but i i screwed it up, and had to go back to a backup off ssi, the hole site went down :)

Anybody up for the challenge?

A


Edit 3: I nailed it :) Even tough i think my quyrey to the databas is way to overkill, as i just twaked the output to suit my needs.
Title: Re: "recent topics" in SMF style
Post by: bloc on November 27, 2006, 06:11:21 PM
Quote from: hartiberlin on November 27, 2006, 04:52:08 AM
Hello,
thanks for all the updates,
but I know have an urgent problem with my hoster.

It says:
There has been a problem with the database!
MySQL reported:
User "hartiberlin" has exceeded the 'max_questions' resource (current value: 70000)

This is a notice email to let you know that SMF could not connect to the database, contact your host if this continues.


Does this Recent Topic use so many queries to the database ?

It seems, my just 39 onliline users at the moment generate
more than 70.000 queries in ONE HOUR ?!

Could this be, or is someone trying to download the whole
forum with a tool or is Google spidering the whole website ?


Sounds you have some kind of loop somwhere. Because even if 39 users fetches 100 topics each, each suer use 1-2 queries for it. But this sounds like a query inside a loop or something.
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 27, 2006, 07:51:13 PM
Bloc, when I display this thread, the stats at the bottom of the page are:
Page created in 0.497 seconds with 37 queries.

Title: Re: "recent topics" in SMF style
Post by: bloc on November 27, 2006, 08:47:30 PM
Yes..but the recent topics query alone has afaik 1-2 queries. Of course the whole forum script + TP will add up.

Edit: I see now he wrote "1 hour" :) ..the big number might then be correct. If we reckon each user clicks once pr.minute and there are 30 users: 30x60x25(approx) queryies. thats roughly 45.000 queires per hour.
Title: Re: "recent topics" in SMF style
Post by: Techdomain on November 27, 2006, 09:22:26 PM
Have to admit - I have never heard of a server having a query limit!
Title: Re: "recent topics" in SMF style
Post by: bloc on November 27, 2006, 09:27:48 PM
No, me either..but thats maybe part of some hosting plans, i don't know.
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 27, 2006, 09:29:28 PM
I believe this is an 'enhancement' of MySQL 5.0:

http://dev.mysql.com/doc/refman/5.0/en/user-resources.html
Title: Re: "recent topics" in SMF style
Post by: bloc on November 27, 2006, 09:43:23 PM
Well, that might explain it..and quite the trouble maker too, it limits what you can use of scripts and how many users can visit at any given time.
Title: Re: "recent topics" in SMF style
Post by: Techdomain on November 27, 2006, 10:57:57 PM
ouch... means just another thing (trap) to look out for when you are choosing a host!
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 12:51:33 AM
Well,
the limit of 70.000 queries now has almost
made my website unaccessible !

I have to click 10 time so I donÂÃ,´t get the
error message !

Please help.

How can I setup TP and SMF1.1RC3,
so it does consume the lowest amount of
Database querries ?
On my hoster I have MySQL 3.x
databases.

But they strictly limit the database queries to
70.000 queries per hour
and now as I had the 100 recent topics on
my TP frontpage and inside the InfoCenter Box
on the forum main page at the bottom,
it seems these 70.000 queries are used
up quite rapidly..

Should I change the most recent topics back to just
10 to have less queries ?

Many thanks.

Best regards, Stefan.
Title: Re: "recent topics" in SMF style
Post by: technodragon73 on November 30, 2006, 03:20:28 AM
Yes you should...each topic listed is at least one query...multiply that by the number of users online each (you mentioned 39 users at any given time) minute is about 4000 queries a minute when you add in the queries for each block as well.
Title: Re: "recent topics" in SMF style
Post by: bloc on November 30, 2006, 06:40:40 PM
The best way to get under that 70.000 limit is of course turning off every mod - including TP - so that SMF runs on just minimal number of queries.
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 30, 2006, 07:10:29 PM
Quote from: Bloc on November 30, 2006, 06:40:40 PM
The best way to get under that 70.000 limit is of course turning off every mod - including TP - so that SMF runs on just minimal number of queries.

True. But I don't think TechnoDragon's characterization is correct. It shouldn't require a query per topic any more than listing messages in a thread would require a query per message to display a thread (you can see this is not the case when you display a topic with only one or two replies and one which has a couple of pages but can be displayed by showing 'All'; the total queries required aren't that different and are more dependent on number of different posters included in the thread).

Similarly, when I display Members (http://www.tinyportal.net/smf/index.php?action=mlist), it shows 30 members on the page without taking over 30 queries (stats show page required 22 queries).

(Of course, it IS possible to hack SMF to connect to the DB using different ID's, each with its own limit of 70k queries/hr.)
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 08:28:38 PM
Where do I see the amount of queries TP with SMF does to the database ?

In my footer it does only display:
Powered by SMF 1.1 RC3 | SMF ÂÃ,© 2001-2006, Lewis Media
TinyPortal v0.9.6beta ÂÃ,© Bloc | Azure design by Bloc
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 08:32:11 PM
How much queries per hour does Tinyportal.net generate about ?

Can I limit the queries to the database, when I have more postings
in each thread ?

So instead showing 10 postings per thread , show 20 postings in each thread
per page ?

Will this reduce the queries load onto the database ?
As the users would just read longer in each page and
donÂÃ,´t need to load so often the next page ?
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 08:35:49 PM
Is a limit of 70.000 queries per hour low ?
What does your hostings providers offer ?

The problem is getting worse now in this moment..
I canÂÃ,´t access almost anymore my own forum...

I only get this limit error...

I had in about 20 hours now 13000 hits to my
startpage.
Is this normal,
when about 30 to 50 users are online all the time in my
overunity.com forum ?
Or could this be a DDOS attack ?


Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 08:40:29 PM
MurphyÂÃ,´s law hits always, as breaking news breaks...
Now somebody can light a 60 Watts bulb with a 9 Volts battery
and now forum does not work reliable...

See:
http://www.overunity.com/index.php/topic,712.2260.html


So how could I easily reduce the queries more,
without deinstalling TinyPortal and the Admod ?
These are the only MODs I use.
Many thanks...
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 30, 2006, 08:53:50 PM
You can show time/queries in your fooer by going to
Admin -> Configuration/Features and Options -> Layout and Options

Check the box after "Display time taken to create every page"

That seems like a serious number of page hits (average near 11 every minute for 20 hours).

Without uninstalling TP, you can start my disabling some blocks and (once you show time/queries) see which ones generate how many queries by enabling them one at a time.

And, with your concern being queries rather than bandwidth over time, serving up more messages per page may give some small benefit.
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 09:01:40 PM
I see, that already each page access over here at tinyportal.co.uk
takes around 35 queries to the database,
so if this is really the case,
I get around with users being online all the time:

70.000 / 50 users x 35 queries = 40 pages
only for each user per hour !
This now is really a low value !

So it seems this is just a very limit for my forum ,
right ?

What maximum queries to the database does your ISP allow ?
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 09:13:39 PM
Okay, now I have enabled
"Display time taken to create every page"

and my forum pages have now between 32 and 36 queries per page
to the database.

Is this normal ?
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on November 30, 2006, 09:24:17 PM
Now as I can see the queries done to the database,
I saw, that the code I had put in there generated 42 queries
to the database for the recent 10 postings !

Now after disabling this bloc it is only 19 queries !
So this is huge difference...
Can anyone post here a code for the last 100 recent postings,
which will only consume 2 to 5 queries to the database ?

Many thanks.
Title: Re: "recent topics" in SMF style
Post by: rebelrose on November 30, 2006, 09:59:28 PM
hartiberlin, you seem very enthusiastic about things, may I make a small suggestion, you posted here 3 times back to back within minutes of each other.

Might I suggest you slow down long enough to allow someone to respond to your first post before adding the second and third.

Sometimes it is easy to overlook a post when they are posted by the same person in a row this way.

When I say overlook I mean they might miss something and not get all your questions answered.

We try our best to give as much support as needed and would hate to over look something.

Thank you so much. ;)
Title: Re: "recent topics" in SMF style
Post by: bloc on December 01, 2006, 10:05:48 PM
I suggest changing hosts rather quick. The way you have to cut down on things just to get under that limit is ridicoulus. What if you - heaven forbid - used VBulletin + VBportal? :P :) SMF is a very lean compared to that.

Disabling blocks that have their own db calls are always good, thats why I try to make TP db calls be as efficient as possible, to reduce the amount of queries. Which incidentally is also something I am quite surprised to still see the Arcade mod doing: having each page use up to 100-120 queries.. :P

And agreed: please use just one post at a time, its confusing to read and answer.
Title: Re: "recent topics" in SMF style
Post by: AzzX on January 25, 2007, 12:13:16 AM
Moving my site from php_fusion to SMF/TP and trying To get the "recent topics" similar to my current site www.ozsource.org

New test site www.ozsource.net

Any tips :)

Thanks lads.
Title: Re: "recent topics" in SMF style
Post by: jacortina on January 25, 2007, 02:29:55 AM
My latest iteration of the Recent topics Article/Block.

I realized the way this was implemented in order to get membergroup colors, it was performing way too many queries.

Quote from: AzzX on January 25, 2007, 12:13:16 AM
Moving my site from php_fusion to SMF/TP and trying To get the "recent topics" similar to my current site www.ozsource.org

New test site www.ozsource.net

Any tips :)

Thanks lads.

I don't know about that javascipt list expansion, but this code can provide that general kind of a 'most recently posted to topics' table.

It can be used in an article with passed in arguments (for a full article type display) or it can be used in a block (center/frontpage) with parameters specified in the block.

There's quite a bit of documentation in the code itself. Look at the section marked "Boardindex Most Recent Topics Arguments". That uses the Admin-specified number for most recent posts to be shown, but you can provide any number for $list_count.

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
$exclude_boards = array(); // KEEP (to preserve variable declaration)
// $exclude_boards = array(5); //  Exclude single board
// $exclude_boards = array(5, 8); //  Exclude multiple boards
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// index.php?page=##;type=started or index.php?page=##;type=started;count=50
// Topics started by current user list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
// Topics started by specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $heading = 'Most Recent Topics You Started';
// $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
// $limit_clause = 'LIMIT 5';
// $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
elseif ($list_type == 'started')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$where_clause = 'ms.ID_MEMBER = '.$_GET['user'];
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics Started by User '.$_GET['user'];
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
}
}
else
{
$where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics You Started';
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics You Started';
}
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';
Title: Re: "recent topics" in SMF style
Post by: AzzX on January 25, 2007, 02:51:35 AM
Cheers - I'll have a good play when I get home.
Great helpful community here, greatly appreciated.
Title: Re: "recent topics" in SMF style
Post by: Ken. on January 25, 2007, 11:20:08 AM
Thanks J.A.Cortina
My attempt is throwing the error below so I'm missing something here. After reading through the code several times and rereading your post many times as well I'm still not seeing the mistake in my code.
None of my changes seem to be correct.  :uglystupid2:
At this point the old code has been put back into service untill the new can be sorted out in a test article.  :)

Parse error: parse error, unexpected $, expecting ',' or ';' in /homepages/46/d100556969/htdocs/mykimbrell/FamilyForum/Sources/Load.php(1708) : eval()'d code(245) : eval()'d code on line 486

EDIT: Never mind! The test article works just fine and it has now replaced the old code as the active article... in copying the code over from J.A.'s post too the article I must have missed some.
Title: Re: "recent topics" in SMF style
Post by: lish425 on March 02, 2007, 06:15:09 PM
Sweet code, I threw it in a php article.  Thanks it works great.
Title: Re: "recent topics" in SMF style
Post by: RvG on March 02, 2007, 06:57:43 PM
Quote from: J.A.Cortina on January 25, 2007, 02:29:55 AM
My latest iteration of the Recent topics Article/Block.

I realized the way this was implemented in order to get membergroup colors, it was performing way too many queries.

Quote from: AzzX on January 25, 2007, 12:13:16 AM
Moving my site from php_fusion to SMF/TP and trying To get the "recent topics" similar to my current site www.ozsource.org

New test site www.ozsource.net

Any tips :)

Thanks lads.

I don't know about that javascipt list expansion, but this code can provide that general kind of a 'most recently posted to topics' table.

It can be used in an article with passed in arguments (for a full article type display) or it can be used in a block (center/frontpage) with parameters specified in the block.

There's quite a bit of documentation in the code itself. Look at the section marked "Boardindex Most Recent Topics Arguments". That uses the Admin-specified number for most recent posts to be shown, but you can provide any number for $list_count.

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
$exclude_boards = array(); // KEEP (to preserve variable declaration)
// $exclude_boards = array(5); //  Exclude single board
// $exclude_boards = array(5, 8); //  Exclude multiple boards
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// index.php?page=##;type=started or index.php?page=##;type=started;count=50
// Topics started by current user list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
// Topics started by specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $heading = 'Most Recent Topics You Started';
// $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
// $limit_clause = 'LIMIT 5';
// $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
elseif ($list_type == 'started')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$where_clause = 'ms.ID_MEMBER = '.$_GET['user'];
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics Started by User '.$_GET['user'];
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
}
}
else
{
$where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics You Started';
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics You Started';
}
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'Ã,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'Ã,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' Ã,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


gee this works great! :)
Title: Re: "recent topics" in SMF style
Post by: akulion on March 05, 2007, 08:33:38 AM
ive added a few screenshots to the recent topics codes mentioned in this thread
Mainly 2 of them:
- Bloc Style Recent Topics (http://www.tinyportal.net/index.php?topic=596.msg54635#msg54635)
- J.A.Cortina Style Recent Topics (http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580)

I will try and do the rest later - but in my opinion those are 2 of th best :up:




Edit: point to latest code version of my code (J.A.Cortina)
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on March 05, 2007, 06:04:11 PM
Quote from: Gobo on March 05, 2007, 08:33:38 AM
ive added a few screenshots to the recent topics codes mentioned in this thread
Mainly 2 of them:
- Bloc Style Recent Topics (http://www.tinyportal.net/index.php?topic=596.msg54635#msg54635)
- J.A.Cortina Style Recent Topics (http://www.tinyportal.net/index.php?topic=596.msg74048#msg74048)

I will try and do the rest later - but in my opinion those are 2 of th best :up:

Cool, screenshots paints a thousand words   :up:
Title: Re: "recent topics" in SMF style
Post by: G6Cad on March 05, 2007, 09:56:01 PM
Tried JACorinas code, but it give me a scroll bar horizontly in the bottom under the last post  ???
Title: Re: "recent topics" in SMF style
Post by: jacortina on March 05, 2007, 10:22:13 PM
Well, all the column specifications are in percentages (with one column unspecified so it should be 'whatever's left').

Are you using it in article or block? What browser (have you tried with more than one)?
Title: Re: "recent topics" in SMF style
Post by: G6Cad on March 06, 2007, 02:12:26 PM
I placed it in an article (replaced the code with the old one from bloc) and saved it.
I have my block panel on my right side only and it have the width of 200pix on the panel
I tried to change the width to 150, but the scroll bar were still there in your code.

Browser both FireFox 2.1 and IE 6.0
Title: Re: "recent topics" in SMF style
Post by: jacortina on March 06, 2007, 02:39:17 PM
Do you have article set to display frame or title. If so, set to display no frame, no title (creates its own borders and title).
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on March 06, 2007, 02:39:46 PM
J.A.Cortina,

I really like your new version of this ... but I found a problem:

Any recent topic that spans more than one page creates an odd character around the page numbering:

This is my topic ÂÃ,« 1 2 ÂÃ,»

Weird eh? Anyone else have this problem?
Title: Re: "recent topics" in SMF style
Post by: G6Cad on March 06, 2007, 02:44:37 PM
Quote from: J.A.Cortina on March 06, 2007, 02:39:17 PM
Do you have article set to display frame or title. If so, set to display no frame, no title (creates its own borders and title).

Will try that :)
Title: Re: "recent topics" in SMF style
Post by: G6Cad on March 06, 2007, 02:50:19 PM
Still the same. have nothing at all turned on exept that it should show on frontpage (still article)

It's there now if you want to see it.

I have 1280x1024 resolution on my screen to so it's not that eather.
Cleard cache, temp internet files to. Still the blue scroll in the bottom,.
It kind of looks like it's in an iframe tag or similar
Title: Re: "recent topics" in SMF style
Post by: jacortina on March 06, 2007, 02:54:12 PM
Quote from: mrbean17 on March 06, 2007, 02:39:46 PM
J.A.Cortina,

I really like your new version of this ... but I found a problem:

Any recent topic that spans more than one page creates an odd character around the page numbering:

This is my topic ÂÃ,« 1 2 ÂÃ,»

Weird eh? Anyone else have this problem?

If you look at the code, the 'double arrows' are assigned in these lines:

if (count($tmppages) <= 5)
$pages = 'Ã,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'Ã,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' Ã,»';



These are the same as the characters above each post here before and after the reply # and date/time.

I assume this has something to do with the character set being used.

try changing each (there are two places):
'Ã,« '
to:
'« '

and the one:
' Ã,»'
to:
' »'
Title: Re: "recent topics" in SMF style
Post by: jacortina on March 06, 2007, 03:07:18 PM
Quote from: G6â„¢ on March 06, 2007, 02:50:19 PM
Still the same. have nothing at all turned on exept that it should show on frontpage (still article)

It's there now if you want to see it.

I have 1280x1024 resolution on my screen to so it's not that eather.
Cleard cache, temp internet files to. Still the blue scroll in the bottom,.
It kind of looks like it's in an iframe tag or similar

Checking the page source, it looks like that's asn older version which had a 'margin' error in it (the < div > that contains this shows as having a -4pix margin, which isn't in the latest code, but may have been in earlier code).

Latest code is in: http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580

(changed Gobo-Aku's pointer up-thread).
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on March 06, 2007, 03:12:02 PM
Thanks for the fast reply.

I searched the code and found 3 instances of the character and simply removed them and all is well.

Thanks again!
Title: Re: "recent topics" in SMF style
Post by: jacortina on March 06, 2007, 03:12:37 PM
A note about the 'double-arrows' problem -

I include text of message with my notifications and when I got the email notification of the post with this problem, it's displayed in my mail (GMail) as:

QuoteI really like your new version of this ... but I found a problem:

Any recent topic that spans more than one page creates an odd character around the page numbering:

This is my topic Ã,« 1 2 Ã,»

Weird eh? Anyone else have this problem?

No funny characters, even though they show up in that post in this thread
( http://www.tinyportal.net/index.php?topic=596.msg115814#msg115814 ).
Title: Re: "recent topics" in SMF style
Post by: G6Cad on March 06, 2007, 03:15:37 PM
QuoteChecking the page source, it looks like that's asn older version which had a 'margin' error in it (the < div > that contains this shows as having a -4pix margin, which isn't in the latest code, but may have been in earlier code).

Latest code is in: http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580

(changed Gobo-Aku's pointer up-thread).

That worked :)

Thank you J.A Cortina :)  :-*
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on March 06, 2007, 05:21:21 PM
J.A.,

The only thing I don't like about yours vs. Bloc's is that when clicking on a topic, it takes you to the original post vs. the new post since last visit.

Is this an easy change?

Thanks
Title: Re: "recent topics" in SMF style
Post by: jacortina on March 06, 2007, 05:25:01 PM
The 'new' icon/graphic will take you there.

Mine works just as a regular topic list works. Subject line is link to first post, <new> graphic to first unread (if any), far right graphic for last post in thread. Plus pages if multiple in thread.
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on March 06, 2007, 06:05:43 PM
Ahhh, I'm smart. Thanks!
Title: Re: "recent topics" in SMF style
Post by: joh87swe on April 18, 2007, 07:12:39 PM
I use this code:
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg3">Senaste inlägg</td></tr> ';
       $what=ssi_recentTopics('5', NULL, 'array');

        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

But I also want to use the same but only to show topics of a certain board. I have many boards and new boards are being added often so it would be wonderful if I only have to set the board id that I want to show topics from.
Thanks for help.

//Johan
Title: Re: "recent topics" in SMF style
Post by: jacortina on April 24, 2007, 02:35:51 PM
Quote from: joh87swe on April 18, 2007, 07:12:39 PM
But I also want to use the same but only to show topics of a certain board. I have many boards and new boards are being added often so it would be wonderful if I only have to set the board id that I want to show topics from.
Thanks for help.

//Johan

Use the code I posted in the 'code' boxes in message:
http://www.tinyportal.net/index.php?topic=1234.msg105411#msg105411

As noted, the first part should be added to the SSI.php file (defines a new SSI function).

You can skip the second code block in that post to use your own from above. What you need to change is:
       $what=ssi_recentTopics('5', NULL, 'array');

To:
       $what=ssi_recentTopics_Include('5', array(##), 'array');

Where '##' is the number (or comma separated list of numbers) of the board(s) you want the recent topics from.
Title: Re: "recent topics" in SMF style
Post by: javier on April 29, 2007, 06:57:07 PM
Currently this code show the


Topic title, author and date,

its possible make in this way?

Topic title, board, author and date,


grettings
Title: Re: "recent topics" in SMF style
Post by: jacortina on April 30, 2007, 01:44:04 PM
What code are you using?
Title: Re: "recent topics" in SMF style
Post by: javier on May 01, 2007, 03:40:14 PM
Excuse my english, i mean, the code all the people use for "recent topics" show the topic title, author and date only.

my question is:

its  possible to modify for show the board title too?

best regards
javier
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 07, 2007, 01:39:30 PM
Are you talking about the pre-made block for 'Recent Topics'?

I asked about code being used because 'all the people' don't use the same thing.
Title: Re: "recent topics" in SMF style
Post by: javier on May 09, 2007, 08:56:58 AM
 sorry, this its the code:

global $scripturl;

echo '

<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('15', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';



Anyways i have not to use this code in obligatory way, all i trying to make its a code for show the recent topics list in this way:

board title - topic title - last post date

excuse my english  :(
Best regards
Javier

Title: Re: "recent topics" in SMF style
Post by: baderick on May 09, 2007, 01:10:54 PM
hi

is there anyway of showing the posters name with there members colour? it shows up in the shout box but i cant seem to figure out how todo it within a block.

thanks

baderick
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 09, 2007, 03:13:30 PM
Quote from: javier on May 09, 2007, 08:56:58 AM
Anyways i have not to use this code in obligatory way, all i trying to make its a code for show the recent topics list in this way:

board title - topic title - last post date

First, if you look in SSI.php for the ssi_RecentTopics function, you'll find where it builds its array to send back (the data that gets put in $what):

// Build the array.
$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 . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?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 . '?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" />',
);


You'll see that board name as a link is stored in ['board']['link'].

Try changing the line:
                                                ', $topic['link'];

To:
                                                ', $topic['board']['link'], ' - ', $topic['link'];
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 09, 2007, 03:29:37 PM
Quote from: baderick on May 09, 2007, 01:10:54 PM
hi

is there anyway of showing the posters name with there members colour? it shows up in the shout box but i cant seem to figure out how todo it within a block.

thanks

baderick

How you'd do it would depend on the nature of the block. If you're just going to get the color for one or to members, I'd most likely try to JOIN the membergroups table to any query for those members.

If you're getting colors for some arbitrary number of members, I'd usually load an array with the colors:

global $db_prefix;

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);


Then, after fetching member info including their primary group (ID_GROUP) and their display name (realName), you'd have lines like:

$color_start = !empty($groupcolors[$row['ID_GROUP']]) ? $groupcolors[$row['ID_GROUP']] : '';

echo '<font color="' . $color_start . '">' . $row['realName'] . '</font>';
Title: Re: "recent topics" in SMF style
Post by: baderick on May 09, 2007, 03:36:55 PM
hi

thanks J.A.Cortina for your fast reply ill try that tonight when i get home from work :)
Title: Re: "recent topics" in SMF style
Post by: katoona on May 10, 2007, 02:37:59 AM
I have set number of posts to 25 for one selected board, but if nobody make any post for few days, the recent posts dissapear until nobody is left.

Is there any workaround for this?
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 10, 2007, 02:42:54 AM
Quote from: katoona on May 10, 2007, 02:37:59 AM
I have set number of posts to 25 for one selected board, but if nobody make any post for few days, the recent posts dissapear until nobody is left.

Is there any workaround for this?

What code are you using (probably best to just include it here between [ code ] & [ /code ] (no spaces).
Title: Re: "recent topics" in SMF style
Post by: katoona on May 10, 2007, 02:50:14 AM
Quoteglobal $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Salg / reklamering for nye produkter</td></tr> ';
       $what=ssi_recentTopics('25', array('1','2','3','4','5','6','7','8','9','10','11','12') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                         <td class="annonser" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>                                       
                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

Sorry, her is the code I am using.
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 10, 2007, 03:09:32 AM
OK, two points.

You're working with the SSI function ssi_recentTopics and when you look in that function you find a large, complex query with the line:
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "

What that means is that the search for topics to list will be limited to message numbers greater than Latest-Msg-Number - (35 * 25) or the last 875 messages.

So as posts go into the boards NOT included in this, the fewer distinct topics are included in the last 875 posts.

The second point is that there is a code snippet to deal with making a version of this function to INCLUDE a specific board (or boards) rather than work on an EXCLUDE basis. It does NOT have the code to limit to a number of recent messages.

See this message:
http://www.tinyportal.net/index.php?topic=1234.msg105411#msg105411

And this one later in the thread:
http://www.tinyportal.net/index.php?topic=1234.msg105913#msg105913
Title: Re: "recent topics" in SMF style
Post by: katoona on May 10, 2007, 03:36:24 AM
Quote('25', array('1','2','3','4','5','6','7','8','9','10','11','12') , 'array');

On my forum the numbers 1-12 excludes those boards from being showed - I thought that these numbers would indicate wich boards that are being showed, and not the other way around.

Its no big deal, just a little curious.
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 10, 2007, 03:42:17 AM
Right.

The one you are using works on an EXCLUDE basis. The new function at the links I gave you work on an INCLUDE basis. And because it's going to look for a more limited range of things, the query doesn't have that message number limit (which is there to save the process from looking through everything on a big forum).

If you use the code at the links I gave you, you won't EXCLUDE 1-12, you'll just INCLUDE 13 (or 13, 14, 15, if you want).

On a forum where boards are added fairly regularly, specifying what to INCLUDE can work better than constantly updating a list of what to EXCLUDE.
Title: Re: "recent topics" in SMF style
Post by: katoona on May 10, 2007, 04:00:03 AM
Quote from: J.A.Cortina on May 10, 2007, 03:09:32 AM
See this message:
http://www.tinyportal.net/index.php?topic=1234.msg105411#msg105411

Ok, I got it, but I did not quite understand exactly where in the SSI.php file I should include your code. I know I am a little stupid, but please help me. Thanks.

You said: look for "(/a)", but can you be a little more spesific?
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 10, 2007, 04:03:38 AM
The SSI.php file is part of the SMF standard set of files.

It's in your forum's root directory, the same place as the index.php.

[And the comment about the /a was about a specific previous post. Ignore it. Add the function in the first large block to the SSI. php. Use the second block or use the line from the second post I pointed to in your own block.]
Title: Re: "recent topics" in SMF style
Post by: katoona on May 10, 2007, 04:04:49 AM
Lol, I am not that stupid, but where inside the file?
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 10, 2007, 04:07:12 AM
It doesn't matter. SSI.php is just a collection of functions. Add it just before the ?> at the end of the file.

(And note the edit to my last post).
Title: Re: "recent topics" in SMF style
Post by: katoona on May 10, 2007, 04:36:11 AM
Again, thanks for your help. It works perfectly.
Title: Re: "recent topics" in SMF style
Post by: katoona on May 13, 2007, 09:23:09 PM
I know that this is a not a support board, but I am trying to write a code to add numbers before each post. This should be fairly easy, but I am completely stuck.

I thought this would be something that others also want to know how to do. I have a attached a manipulated picture of what I am trying to accomplish.

Title: Re: "recent topics" in SMF style
Post by: jacortina on May 13, 2007, 10:20:54 PM
These are simply to enumerate the lines?

What code are you using?

Basically, you'll set a counter variable to zero before you loop through the entries and increment it.
Title: Re: "recent topics" in SMF style
Post by: katoona on May 13, 2007, 10:50:06 PM
Quoteglobal $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Selges</td></tr> ';
       $what=ssi_recentTopics_Include(60,array(1,2,3,4,5,6,7,8,9,10,11),'return');


        foreach ($what as $topic)
        {
                echo '
                                <tr> <td ' , ' class="windowbg2" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

            // Is this topic new? (assuming they are logged in!)
            if (!$topic['new'] && $context['user']['is_logged'])
               echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/ny.gif" alt="', $txt[302], '" border="0" />';

            else
               echo '<img src="', $settings['images_url'], '/ny_ikke.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '</a>
            </td>

                                         <td class="annonser" height="22" valign="middle">
                                                ', $topic['link'],'

               </td>                                       
                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

I am using the above code to show recent posts in a center block, and now I am using the left field to show "new" indicator, but I am planning to move the "new" indicator somewhere else and replace it with numeric.
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 13, 2007, 11:06:58 PM
Well, this adds a column to the far left and puts the number there (note the 'colspan' paramter in the 5th line; that should equal the total number of columns).

global $scripturl, $txt, $settings, $context;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="4" class="catbg">Selges</td></tr> ';
       $what=ssi_recentTopics_Include(60,array(1,2,3,4,5,6,7,8,9,10,11),'return');

$counter = 0;

        foreach ($what as $topic)
        {

$counter += 1;
                echo '
                                <tr> <td class="windowbg2" valign="middle" align="center" width="4%">', $counter, '</td>';

                echo '
                                <td ' , ' class="windowbg2" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/ny.gif" alt="', $txt[302], '" border="0" />';

else
echo '<img src="', $settings['images_url'], '/ny_ikke.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

echo '</a>
</td>

                                         <td class="annonser" height="22" valign="middle">
                                                ', $topic['link'],'

               </td>                                       
                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: katoona on May 13, 2007, 11:11:20 PM
Wow, that was fast. Thank you so much.  ;D ;D ;D
Title: Re: "recent topics" in SMF style
Post by: siyah11 on May 22, 2007, 08:41:58 AM
thank you
Title: Re: "recent topics" in SMF style
Post by: texasflats on May 26, 2007, 04:59:43 PM
Whew, I got it working. Thank you!!  :)

I don't want to be a pain, but would it be real complicated to add the author of the topic and maybe a brief summary of the post?

The code I'm using is:
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Texas Fishing Reports</td></tr> ';
       $what=ssi_recentTopics_Include(3,array(5),'return');


        foreach ($what as $topic)
        {
                echo '
                                <tr> <td ' , ' class="windowbg" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

            // Is this topic new? (assuming they are logged in!)
            if (!$topic['new'] && $context['user']['is_logged'])
               echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/on.gif" alt="', $txt[302], '" border="0" />';

            else
               echo '<img src="', $settings['images_url'], '/on2.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '
            </td>

                                         <td class="windowbg2" height="22" valign="middle">
                                                ', $topic['link'],'

               </td>                                       
                                        <td class="windowbg" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


It is 3 columns. I'd like to add the summary to the center column and the author to the right column if possible.

You can see it at http://texasflats.net/
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 26, 2007, 06:40:24 PM
Without extensive re-work, you can only work with what's returned from the ssi function called. That gives last poster name (not the original topic starter) and it gives up to the first 128 characters of the message.

Try this:
global $scripturl, $txt;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Texas Fishing Reports</td></tr> ';
       $what=ssi_recentTopics_Include(3,array(5),'return');


        foreach ($what as $topic)
        {
                echo '
                                <tr> <td ' , ' class="windowbg" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

            // Is this topic new? (assuming they are logged in!)
            if (!$topic['new'] && $context['user']['is_logged'])
               echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/on.gif" alt="', $txt[302], '" border="0" />';

            else
               echo '<img src="', $settings['images_url'], '/on2.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '
            </td>

                                         <td class="windowbg2" valign="middle">
                                                ', $topic['link'],'<br />

                                                <span class="smalltext">
                                                        ', $topic['body'], '
                                                </span>
               </td>                                       
                                        <td class="windowbg" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '<br />', $topic['poster']['link'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: texasflats on May 26, 2007, 08:37:19 PM
Thanks J.A.Cortina. I gave that a try, it works as you said with the exception of the 128 chars wouldn't show up, and the topic titles link to the last reply which doesn't work for what I'm wanting.

If it's a big deal I'll just keep what I have, but I do appreciate your response and EFFORT.

Thanks!
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 26, 2007, 09:12:31 PM
The topic title links to the first unread in the topic. That is exactly the same as in the code you posted. I didn't change the array entry being used for that. It's $topic['link'] in both code blocks.

I would need to see the ssi_recentTopics_Include code (from your SSI.php file) to implement the 128 bytes of body text.
Title: Re: "recent topics" in SMF style
Post by: texasflats on May 27, 2007, 03:05:21 PM
DOH!! Your right.  :uglystupid2:

Would it be possible to make it link to the original topic?

The code in my SSI.php:

function ssi_recentTopics_Include($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$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 . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?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 . '?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" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $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>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}


Thanks again!  :)
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 27, 2007, 03:20:37 PM
Here you go. My mistake on the 128 character array entry name. Also changes link to start of thread:
global $scripturl, $txt;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Texas Fishing Reports</td></tr> ';
       $what=ssi_recentTopics_Include(3,array(5),'return');


        foreach ($what as $topic)
        {
                echo '
                                <tr> <td ' , ' class="windowbg" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

            // Is this topic new? (assuming they are logged in!)
            if (!$topic['new'] && $context['user']['is_logged'])
               echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/on.gif" alt="', $txt[302], '" border="0" />';

            else
               echo '<img src="', $settings['images_url'], '/on2.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '
            </td>

                                         <td class="windowbg2" valign="middle">
                                                ', '<a href="' . $scripturl . '?topic=' . $topic['topic'] . '.msg0">' . $topic['subject'] . '</a>','<br />

                                                <span class="smalltext">
                                                        ', $topic['preview'], '
                                                </span>
               </td>                                       
                                        <td class="windowbg" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '<br />', $topic['poster']['link'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: mixman on May 27, 2007, 04:47:06 PM
Quote from: Bloc on August 17, 2005, 12:01:38 PM
- add board ID number like to the function if youw ant to narrow down the boards recent topics are taken from. change it to ssi_recentTopics('8', array('3','56') , 'array') where the numbers 3 and 56 are examples of board ID's.


Are those board #3 and #56? I tried several several different combinations of numbers to pull the 5 latest messages out of board 2. Can not get this to work...
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 27, 2007, 04:57:49 PM
Those are boards to EXCLUDE. That's how the SSI function for Recent Topics was written.

If you look up in this thread a couple of messages, http://www.tinyportal.net/index.php?topic=596.msg134627#msg134627 , you'll see a function that you can add to your SSI.php file (right before the "?>" at the end).

Then you'd call ssi_recentTopics_Include(5, array(2), 'array') .
Title: Re: "recent topics" in SMF style
Post by: texasflats on May 27, 2007, 05:34:57 PM
Is it possible to make it pull the 128 chars from the original topic? The way it is, it pulls from the last reply.

Everything else is perfect, I can't thank you enough for all your help.
Title: Re: "recent topics" in SMF style
Post by: mixman on May 27, 2007, 05:58:07 PM
Quote from: J.A.Cortina on May 27, 2007, 04:57:49 PM
If you look up in this thread a couple of messages, http://www.tinyportal.net/index.php?topic=596.msg134627#msg134627 , you'll see a function that you can add to your SSI.php file (right before the "?>" at the end).

Then you'd call ssi_recentTopics_Include(5, array(2), 'array') .

Thanks! One action less untill launch :)
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 27, 2007, 06:25:55 PM
Quote from: texasflats on May 27, 2007, 05:34:57 PM
Is it possible to make it pull the 128 chars from the original topic? The way it is, it pulls from the last reply.

Everything else is perfect, I can't thank you enough for all your help.

Not without a good amount of re-engineering of the SSI function or adding significant processing to  your block. The query it runs in the SSI function is specifically looking for the most recent activity. Building a link to the first message from the topic ID for a link is trivial (message #0 within a topic will point there). But the query pulls all the info for the most recent message posted in a topic. It would require adding the processing to first get the most recent posted to topics and then go back for each of those and read in the first message in that topic.

I'll take a look at it, but not sure when/if I can get something to you.
Title: Re: "recent topics" in SMF style
Post by: insanemustang on June 18, 2007, 11:08:14 PM
I really like this block.  I was wondering (hopefully it hasn't been posted and I missed it) how I could add the # of replies that have been made already?

I just need the specific coding and where to put it of the code below to make this happen, as I have already edited the look/function of my block

An example is here ---> http://www.bamanation.net

global $scripturl;
echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan=1>Topic</td><td>Most Recent Poster</td><td>Date</td></tr> ';
       $what=ssi_recentTopics('8', array('1','2','4','5','6','9','10','11','12','13','14','15','17','18','19','20','21','22','23',) , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle"><font size=1>
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </font></td>
                                        <td class="windowbg2" valign="middle" width="20%"><font size=1>
                                                ', $topic['poster']['link'], '
                                        </font></td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                echo '
                                                <span class="smalltext"><font size=1>
                                                        ', $topic['time'], '
                                                </font></span>


                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
echo'<br>';
Title: Re: "recent topics" in SMF style
Post by: IchBin on June 18, 2007, 11:31:33 PM
Number of replies to the recent topic? Not something easily added, but possible. It would probably require a join of some sort to get a count of the posts in a topic. Don't have the time to look at it just yet.
Title: Re: "recent topics" in SMF style
Post by: jacortina on June 19, 2007, 12:24:37 AM
The code you're using is fully dependent on the SSI function and what gets returned by it.

That's the "$what=ssi_recentTopics(...".

numReplies (from the topics table) isn't one of the fields that the function reads from the database (so it doesn't pass it back in the array).

Others have made use of a custom version of the ssi_recentTopics function to use on an INCLUDE basis (the standard one works on an EXCLUDE basis).

Put this function at the end of your SSI.php file (right before the "?>"):
function ssi_recentTopics_Include($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead, t.numReplies,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$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'],
'numReplies' => $row['numReplies'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?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 . '?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" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $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>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}


I've already added the code to get the numReplies column from the topcs table in the above function.

Then change the line in your code:
       $what=ssi_recentTopics('8', array('1','2','4','5','6','9','10','11','12','13','14','15','17','18','19','20','21','22','23',) , 'array');

To (array is list of boards to INCLUDE, now):
       $what=ssi_recentTopics_Include('8', array('3','7','8','16') , 'array');

Then it's a matter of how you want that number to appear. It's held in the array variable $topic['numReplies'].
Title: Re: "recent topics" in SMF style
Post by: insanemustang on June 19, 2007, 03:57:41 AM
I will try this tomorrow.  Thanks for your help.

Quote from: J.A.Cortina on June 19, 2007, 12:24:37 AM
The code you're using is fully dependent on the SSI function and what gets returned by it.

That's the "$what=ssi_recentTopics(...".

numReplies (from the topics table) isn't one of the fields that the function reads from the database (so it doesn't pass it back in the array).

Others have made use of a custom version of the ssi_recentTopics function to use on an INCLUDE basis (the standard one works on an EXCLUDE basis).

Put this function at the end of your SSI.php file (right before the "?>"):
function ssi_recentTopics_Include($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead, t.numReplies,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$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'],
'numReplies' => $row['numReplies'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?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 . '?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" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $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>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}


I've already added the code to get the numReplies column from the topcs table in the above function.

Then change the line in your code:
       $what=ssi_recentTopics('8', array('1','2','4','5','6','9','10','11','12','13','14','15','17','18','19','20','21','22','23',) , 'array');

To (array is list of boards to INCLUDE, now):
       $what=ssi_recentTopics_Include('8', array('3','7','8','16') , 'array');

Then it's a matter of how you want that number to appear. It's held in the array variable $topic['numReplies'].
Title: Re: "recent topics" in SMF style
Post by: insanemustang on June 27, 2007, 06:47:50 PM
I really like this addition to my site.  I do have a question though.  I know that the block is for "recent/new" topics.  But I set the display to show the most recent 8, and after 2 or 3 days they stop showing on this block, and I don't even have a total of 8 yet...

I looked at the script and I don't see a number of days or anything that I can edit.

Any ideas?
Title: Re: "recent topics" in SMF style
Post by: jacortina on June 27, 2007, 07:14:58 PM
Are you actually using the new code above (the version with the ssi_recentTopics_Include)?

If you use the original ssi_recentTopics (with list of boards to 'exclude') you are also using the standard code which puts limits on how far back to look. ssi_recentTopics code only scans the last 35 * (# of topics to show) msg #'s. So, if you're using that, it only looks in the most recent 280 ( 35 * 8 ) posts for topics to show.
Title: Re: "recent topics" in SMF style
Post by: insanemustang on June 27, 2007, 08:45:55 PM
Quote from: J.A.Cortina on June 27, 2007, 07:14:58 PM
Are you actually using the new code above (the version with the ssi_recentTopics_Include)?

If you use the original ssi_recentTopics (with list of boards to 'exclude') you are also using the standard code which puts limits on how far back to look. ssi_recentTopics code only scans the last 35 * (# of topics to show) msg #'s. So, if you're using that, it only looks in the most recent 280 (35 * 8) posts for topics to show.

Thank you, I didn't really understand the include ssi until I took some time today and really looked at it.

I'm still learning, thanks for your help, it works great.
Title: Re: "recent topics" in SMF style
Post by: Avinash on July 06, 2007, 02:06:06 AM
I'm trying to use this as a module in joomla, and it works, but the recent topics overlaps some of my content. Any ideas?
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 06, 2007, 02:16:38 AM
Sorry. But, I'm not at all familiar with Joomla, so I wouldn't even know where to start looking for the glitch.
Title: Re: "recent topics" in SMF style
Post by: hvyhitter on July 21, 2007, 04:01:36 PM
i came in search of a different format for the recent posts block.. WOW.. did I ever get it.. awesome.. thanks BLOC!

TINYPORTAL ROX
Title: Re: "recent topics" in SMF style
Post by: hvyhitter on July 24, 2007, 06:31:59 PM
works like a charm.. but me.. I am always trying to tweak it a little bit..
2 things

1. Is there a easy way to add a header row?
2. Can I add a column that has the original Message Icon in it. At my place the message Icons are used for certain posts. I like to see those..

How can I add a 4th field into that

this is what it looks like now

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg162.imageshack.us%2Fimg162%2F39%2Frecentpostsnowfu8.jpg&hash=5cd4c445d83180512998d38389cb5e2ac7c21c40)

This is the desired effect AFTER.

notice the blue crown for admin threads.

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg485.imageshack.us%2Fimg485%2F5373%2Frecentpoststhente6.jpg&hash=5b5967478929e20b71c1948f4eee38661e0df212)

i am planning to suggest that people use the message icons to categorize their posts.. This will be a good way of reinforcing that idea.
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 24, 2007, 07:23:39 PM
You might want to look at: http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580

That's code to use in a block or article to output recent topics in the full style (like when you click 'Show Unread' in the User Box). It gives column headings, but they are NOT usable for re-sorting.
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 28, 2007, 06:33:43 PM
Quote from: J.A.Cortina on January 25, 2007, 02:29:55 AM

I don't know about that javascipt list expansion, but this code can provide that general kind of a 'most recently posted to topics' table.

It can be used in an article with passed in arguments (for a full article type display) or it can be used in a block (center/frontpage) with parameters specified in the block.

There's quite a bit of documentation in the code itself. Look at the section marked "Boardindex Most Recent Topics Arguments". That uses the Admin-specified number for most recent posts to be shown, but you can provide any number for $list_count.

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
$exclude_boards = array(); // KEEP (to preserve variable declaration)
// $exclude_boards = array(5); //  Exclude single board
// $exclude_boards = array(5, 8); //  Exclude multiple boards
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// index.php?page=##;type=started or index.php?page=##;type=started;count=50
// Topics started by current user list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
// Topics started by specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $heading = 'Most Recent Topics You Started';
// $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
// $limit_clause = 'LIMIT 5';
// $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
elseif ($list_type == 'started')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$where_clause = 'ms.ID_MEMBER = '.$_GET['user'];
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics Started by User '.$_GET['user'];
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
}
}
else
{
$where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics You Started';
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics You Started';
}
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'Ã,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'Ã,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' Ã,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


Hi,
what parameters do I have to set manually in this script to show the latest 200 postings
on the frontpage after my own frontpage bloc ?

Which lines do I have to edit and can I just put it into a frontpage PHP bloc
below my own front page bloc ?

How can I insert my Google adsense horizontal banner
after each 20 listed postings ?

Many thanks.
Title: Re: "recent topics" in SMF style
Post by: hvyhitter on July 28, 2007, 07:44:20 PM
Quote from: J.A.Cortina on July 24, 2007, 07:23:39 PM
You might want to look at: http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580

That's code to use in a block or article to output recent topics in the full style (like when you click 'Show Unread' in the User Box). It gives column headings, but they are NOT usable for re-sorting.

yeah I saw that code.. but I am at a loss for how I would add that to tiny portal.. That is what I am looking for

but as I am wondering is if that will cause an increase in the number of database hits thus increasing the server load. If that is the case.. it probably isnt worth it. The one I got now.. is quite nice.
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 29, 2007, 05:19:35 AM
Hmm,
I tried now to modify this script from
J.A.Cortina
to list the last recent 200 postings,
and put it into a PHP bloc onto the frontpage in TinyPortal
but it only shows 64 postings, not 200 !
Have a look at:
www.overunity.com

How can I get a working last 200 postings ?

Here is the code:

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
$exclude_boards = array(); // KEEP (to preserve variable declaration)
// $exclude_boards = array(5); //  Exclude single board
// $exclude_boards = array(5, 8); //  Exclude multiple boards
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// index.php?page=##;type=started or index.php?page=##;type=started;count=50
// Topics started by current user list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
// Topics started by specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $heading = 'Most Recent Topics You Started';
// $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
// $limit_clause = 'LIMIT 5';
// $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 200;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 200;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 200)
$list_count = 200;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
elseif ($list_type == 'started')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$where_clause = 'ms.ID_MEMBER = '.$_GET['user'];
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics Started by User '.$_GET['user'];
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
}
}
else
{
$where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics You Started';
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics You Started';
}
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'Ã,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'Ã,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' Ã,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';



P.S: I did not modify any SSI.php
file and I also donÃ,´t want a solution that modifies the
SSI.php file.


2. How can I have my Google Adsense banner code being inserted
every 20 entries ?
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 29, 2007, 05:37:33 AM
That clause is:
        if (empty($settings['number_recent_posts']))
               $number_recent_posts = 200;
       else
               $number_recent_posts = $settings['number_recent_posts'];


So, I'd guess that you have the 'number of recent posts' set to 64 in your Admin.

Try changing to:
//        if (empty($settings['number_recent_posts']))
               $number_recent_posts = 200;
//       else
//               $number_recent_posts = $settings['number_recent_posts'];


And this is independent of SSI.php - doesn't use it, doesn't require changing it.
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 29, 2007, 05:41:00 AM
Quote from: hvyhitter on July 28, 2007, 07:44:20 PM
yeah I saw that code.. but I am at a loss for how I would add that to tiny portal.. That is what I am looking for

but as I am wondering is if that will cause an increase in the number of database hits thus increasing the server load. If that is the case.. it probably isnt worth it. The one I got now.. is quite nice.

Like it says, you can use it in an article. Or you can use it in a block you set for the front page. There's a bunch of commenting inside to help.

ANd, of course, it has to go to the databse. But whatever you're using now has to query the databse, too.
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 29, 2007, 06:02:34 AM
Quote from: J.A.Cortina on July 29, 2007, 05:37:33 AM

So, I'd guess that you have the 'number of recent posts' set to 64 in your Admin.


No,
it is set also to 200.

But I really want to get rid of it below the forum.
I only want it to have on the front page,
so can I set the 'number of recent posts' to 0  in my Admin area ?
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 29, 2007, 06:11:49 AM
Quote from: J.A.Cortina on July 29, 2007, 05:37:33 AM
That clause is:
        if (empty($settings['number_recent_posts']))
               $number_recent_posts = 200;
       else
               $number_recent_posts = $settings['number_recent_posts'];


So, I'd guess that you have the 'number of recent posts' set to 64 in your Admin.

Try changing to:
//        if (empty($settings['number_recent_posts']))
               $number_recent_posts = 200;
//       else
//               $number_recent_posts = $settings['number_recent_posts'];



Okay, I made this edit and it still shows only about 64 postings !
the "number of recent posts" in my admin area is still set to 200.

Have a look at the frontpage of
www.overunity.com

Thanks.
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 29, 2007, 02:14:14 PM
All this time and I had 'min' when it should have been 'max'. Wow.

Try the code below. I stripped out the extra comments and the processing to check inputs (that's for when it's loaded as an article with possible paramters - with 'constant' parameters, you don't need it).

If that doesn't solve it, find this line:
      $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * max($list_count, 5));


and replace it with:
      $where_clause = '';


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
       $exclude_boards = array();      // KEEP (to preserve variable declaration)
//      $exclude_boards = array(5);     //  Exclude single board
//      $exclude_boards = array(5, 8);  //  Exclude multiple boards
       $ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//


       $do_query = 1;

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
//      Comment out the Info Center's Most Recent Posts Code and Insert this
//      to show Most Recent Topics in full detail style instead
//
      $list_count = 200;
      $heading = 'Most Recently Posted To Topics';
      $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * max($list_count, 5));
      $limit_clause = 'LIMIT ' . $list_count;
      $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////


       $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
       $icon_sources = array();
       foreach ($stable_icons as $icon)
               $icon_sources[$icon] = 'images_url';

       $groupcolors = array();
       $request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
       while ($row = mysql_fetch_assoc($request))
               $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
       mysql_free_result($request);

       $topics = array();

       if ($do_query == 1)
       {
       $request = db_query("
               SELECT
                               ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
                               t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
                               ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
                               IFNULL(meml.realName, ml.posterName) AS lastPosterName,
                               mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
                               ml.subject AS lastSubject, b.memberGroups,
                               ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
                               LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
                               ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
                               . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
                       FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
                               LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
                               LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
                       WHERE " . $where_clause . $ex_board_clause . "
                               AND t.ID_TOPIC = ms.ID_TOPIC
                               AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
                               AND ms.ID_MSG = t.ID_FIRST_MSG
                               AND ml.ID_MSG = t.ID_LAST_MSG
                               AND " . $user_info['query_see_board'] . "
                       ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


       $topic_ids = array();
       while ($row = mysql_fetch_assoc($request))
       {
               if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
                       continue;

               $topic_ids[] = $row['ID_TOPIC'];

               // Clip the strings first because censoring is slow :/. (for some reason?)
               $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
               if (strlen($row['firstBody']) > 128)
                       $row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
               $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
               if (strlen($row['lastBody']) > 128)
                       $row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

                       $row['lastSubject'] = $row['firstSubject'];
                       $row['lastBody'] = $row['firstBody'];

               // Decide how many pages the topic should have.
               $topic_length = $row['numReplies'] + 1;
               if ($topic_length > $modSettings['defaultMaxMessages'])
               {
                       $tmppages = array();
                       $tmpa = 1;
                       for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
                       {
                               $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
                               $tmpa++;
                       }
                       // Show links to all the pages?
                       if (count($tmppages) <= 5)
                               $pages = 'ÂÃ,« ' . implode(' ', $tmppages);
                       // Or skip a few?
                       else
                               $pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

                       if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
                               $pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
                       $pages .= ' ÂÃ,»';
               }
               else
                       $pages = '';

               // We need to check the topic icons exist... you can never be too sure!
               if (empty($modSettings['messageIconChecks_disable']))
               {
                       // First icon first... as you'd expect.
                       if (!isset($icon_sources[$row['firstIcon']]))
                               $icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
                       // Last icon... last... duh.
                       if (!isset($icon_sources[$row['lastIcon']]))
                               $icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
               }

               $color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
               $color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

               // And build the array.
               $topics[$row['ID_TOPIC']] = array(
                       'id' => $row['ID_TOPIC'],
                       'first_post' => array(
                               'id' => $row['ID_FIRST_MSG'],
                               'member' => array(
                                       'name' => $row['firstPosterName'],
                                       'id' => $row['ID_FIRST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
                                       'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
                               ),
                               'time' => timeformat($row['firstPosterTime']),
                               'timestamp' => forum_time(true, $row['firstPosterTime']),
                               'subject' => $row['firstSubject'],
                               'preview' => $row['firstBody'],
                               'icon' => $row['firstIcon'],
                               'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
                       ),
                       'last_post' => array(
                               'id' => $row['ID_LAST_MSG'],
                               'member' => array(
                                       'name' => $row['lastPosterName'],
                                       'id' => $row['ID_LAST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
                                       'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
                               ),
                               'time' => timeformat($row['lastPosterTime']),
                               'timestamp' => forum_time(true, $row['lastPosterTime']),
                               'subject' => $row['lastSubject'],
                               'preview' => $row['lastBody'],
                               'icon' => $row['lastIcon'],
                               'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
                       ),
                       'new' => $row['isRead'],
                       'new_from' => $row['new_from'],
                       'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
                       'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
                       'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
                       'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
                       'is_locked' => !empty($row['locked']),
                       'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
                       'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
                       'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
                       'is_posted_in' => false,
                       'icon' => $row['firstIcon'],
                       'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                       'subject' => $row['firstSubject'],
                       'pages' => $pages,
                       'replies' => $row['numReplies'],
                       'views' => $row['numViews'],
                       '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>'
                       )
               );

               determineTopicClass($topics[$row['ID_TOPIC']]);
       }
       mysql_free_result($request);

       if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
       {
               $result = db_query("
                       SELECT ID_TOPIC
                       FROM {$db_prefix}messages
                       WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
                               AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
               while ($row = mysql_fetch_assoc($result))
               {
                       if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
                       {
                               $topics[$row['ID_TOPIC']]['is_posted_in'] = true;
                               $topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
                       }
               }
               mysql_free_result($result);
       }

       }

if (!empty($topics))
   {
   echo '
       <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
           <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
               <tr>';

   echo '
                   <td class="titlebg" colspan="7">', $heading, '</td>';
   echo '
               </tr>';

   echo '
                               <tr class="titlebg">
                                       <td width="10%" colspan="2"> </td>
                                       <td>', $txt[70], '
                                       </td><td width="14%">', $txt[109], '
                                       </td><td width="4%" align="center">', $txt[110], '
                                       </td><td width="4%" align="center">', $txt[301], '
                                       </td><td width="24%">', $txt[111], '
                                       </td>
                               </tr>';

       foreach ($topics as $topic)
       {
               // Do we want to seperate the sticky and lock status out?
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

               echo '
                               <tr>
                                       <td class="windowbg2" valign="middle" align="center" width="6%">
                                               <img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
                                       </td><td class="windowbg2" valign="middle" align="center" width="4%">
                                               <img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
                                       </td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
                                       if ($topic['new'] == 0)
                                               {
                                               echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
                                               }
                                       echo '
                                       <span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
                                       <td class="windowbg2" valign="middle" width="14%">
                                               ', $topic['first_post']['member']['link'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['replies'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['views'], '</td>
                                       <td class="windowbg2" valign="middle" width="22%">
                                               <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
                                               <span class="smalltext">
                                                       ', $topic['last_post']['time'], '<br />
                                                       ', $txt[525], ' ', $topic['last_post']['member']['link'], '
                                               </span>
                                       </td>
                               </tr>';
       }

   echo '</table></div>';

   }
       else
           echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 30, 2007, 04:48:27 AM
Okay, that long code now worked without the change of the 1 line code.

Now I only have as "(" and ")" characters now some strange:
ÂÃ,«   and   Ãƒâ€šÃ,»

characters..
How can I solve this ?

Many thanks again.

P.S: Is it possible with the Admod to place Adsense banner code
between each 50 listings there ?
Or how could I manually insert an Adsense code now there ?

Many thanks again.
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 30, 2007, 03:10:29 PM
The odd character problem has come up before (earlier in this huge thread).

See http://www.tinyportal.net/index.php?topic=596.msg115824#msg115824


About inserting something after every X number of entries, you'd find the lines:
foreach ($topics as $topic)
{


And do something like:
ad_ctr = 0;
foreach ($topics as $topic)
{
ad_ctr += 1;
if (ad_ctr > 50)
{
ad_ctr = 1;
echo '<tr><td colspan="7">';

[*[*[ CODE TO ECHO/OUTPUT WHAT YOU WANT INSERTED ]*]*]

echo '</td></tr>';
}
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 30, 2007, 11:09:26 PM
Quote from: J.A.Cortina on July 30, 2007, 03:10:29 PM
The odd character problem has come up before (earlier in this huge thread).

See http://www.tinyportal.net/index.php?topic=596.msg115824#msg115824



Thanks,
somehow when I looked at my code,
there were these strange  characters already infront of the << characters there,
so it has been some kind of copy and paste problem.
I just deleted them now and it works.


Quote


About inserting something after every X number of entries, you'd find the lines:
foreach ($topics as $topic)
{


And do something like:
ad_ctr = 0;
foreach ($topics as $topic)
{
ad_ctr += 1;
if (ad_ctr > 50)
{
ad_ctr = 1;
echo '<tr><td colspan="7">';

[*[*[ CODE TO ECHO/OUTPUT WHAT YOU WANT INSERTED ]*]*]

echo '</td></tr>';
}



Where do you define the

"after every X number of entries"

here in the above code ?
I donÃ,´t see that.
Many thanks
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 30, 2007, 11:14:36 PM
It's the '50' in:
if (ad_ctr > 50)

(you DID mention "between each 50 listings" in your last post).
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 30, 2007, 11:30:28 PM
Ahh, I see, yes, 50 entries.
Thanks.

P.S: When I compare the output of your code with the RSS feed or the
200 recent postings below the forum ,
I see, that some postings are missing in your listing.

Why is that ?
Many thanks.
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 30, 2007, 11:34:21 PM
I don't know what your RSS feed is configured for, but unless you've modified it, the list below the forum is 'Recent Posts". This block is NOT Recent Posts, it's "Recent Topics".

That is, it's the most recently posted to topics and a topic will only appear in the list once.
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 30, 2007, 11:50:38 PM
Quote from: J.A.Cortina on July 30, 2007, 11:34:21 PM
I don't know what your RSS feed is configured for, but unless you've modified it, the list below the forum is 'Recent Posts". This block is NOT Recent Posts, it's "Recent Topics".

That is, it's the most recently posted to topics and a topic will only appear in the list once.
Quote from: J.A.Cortina on July 30, 2007, 11:34:21 PM
I don't know what your RSS feed is configured for, but unless you've modified it, the list below the forum is 'Recent Posts". This block is NOT Recent Posts, it's "Recent Topics".

That is, it's the most recently posted to topics and a topic will only appear in the list once.
Quote from: J.A.Cortina on July 30, 2007, 11:34:21 PM
I don't know what your RSS feed is configured for, but unless you've modified it, the list below the forum is 'Recent Posts". This block is NOT Recent Posts, it's "Recent Topics".

That is, it's the most recently posted to topics and a topic will only appear in the list once.


Okay, yes, then that is a bit different, but okay, that is also good and I leave it this way
and also leave the 200 recent postings directly below the forum page.


Now when I tried to insert my Adsense code like this:

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
       $exclude_boards = array();      // KEEP (to preserve variable declaration)
//      $exclude_boards = array(5);     //  Exclude single board
//      $exclude_boards = array(5, 8);  //  Exclude multiple boards
       $ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//


       $do_query = 1;

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
//      Comment out the Info Center's Most Recent Posts Code and Insert this
//      to show Most Recent Topics in full detail style instead
//
      $list_count = 200;
      $heading = 'Most Recently Posted To Topics';
      $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * max($list_count, 5));
      $limit_clause = 'LIMIT ' . $list_count;
      $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////


       $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
       $icon_sources = array();
       foreach ($stable_icons as $icon)
               $icon_sources[$icon] = 'images_url';

       $groupcolors = array();
       $request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
       while ($row = mysql_fetch_assoc($request))
               $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
       mysql_free_result($request);

       $topics = array();

       if ($do_query == 1)
       {
       $request = db_query("
               SELECT
                               ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
                               t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
                               ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
                               IFNULL(meml.realName, ml.posterName) AS lastPosterName,
                               mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
                               ml.subject AS lastSubject, b.memberGroups,
                               ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
                               LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
                               ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
                               . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
                       FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
                               LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
                               LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
                       WHERE " . $where_clause . $ex_board_clause . "
                               AND t.ID_TOPIC = ms.ID_TOPIC
                               AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
                               AND ms.ID_MSG = t.ID_FIRST_MSG
                               AND ml.ID_MSG = t.ID_LAST_MSG
                               AND " . $user_info['query_see_board'] . "
                       ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


       $topic_ids = array();
       while ($row = mysql_fetch_assoc($request))
       {
               if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
                       continue;

               $topic_ids[] = $row['ID_TOPIC'];

               // Clip the strings first because censoring is slow :/. (for some reason?)
               $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
               if (strlen($row['firstBody']) > 128)
                       $row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
               $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
               if (strlen($row['lastBody']) > 128)
                       $row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

                       $row['lastSubject'] = $row['firstSubject'];
                       $row['lastBody'] = $row['firstBody'];

               // Decide how many pages the topic should have.
               $topic_length = $row['numReplies'] + 1;
               if ($topic_length > $modSettings['defaultMaxMessages'])
               {
                       $tmppages = array();
                       $tmpa = 1;
                       for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
                       {
                               $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
                               $tmpa++;
                       }
                       // Show links to all the pages?
                       if (count($tmppages) <= 5)
                               $pages = 'Ã,« ' . implode(' ', $tmppages);
                       // Or skip a few?
                       else
                               $pages = 'Ã,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

                       if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
                               $pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
                       $pages .= ' Ã,»';
               }
               else
                       $pages = '';

               // We need to check the topic icons exist... you can never be too sure!
               if (empty($modSettings['messageIconChecks_disable']))
               {
                       // First icon first... as you'd expect.
                       if (!isset($icon_sources[$row['firstIcon']]))
                               $icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
                       // Last icon... last... duh.
                       if (!isset($icon_sources[$row['lastIcon']]))
                               $icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
               }

               $color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
               $color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

               // And build the array.
               $topics[$row['ID_TOPIC']] = array(
                       'id' => $row['ID_TOPIC'],
                       'first_post' => array(
                               'id' => $row['ID_FIRST_MSG'],
                               'member' => array(
                                       'name' => $row['firstPosterName'],
                                       'id' => $row['ID_FIRST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
                                       'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
                               ),
                               'time' => timeformat($row['firstPosterTime']),
                               'timestamp' => forum_time(true, $row['firstPosterTime']),
                               'subject' => $row['firstSubject'],
                               'preview' => $row['firstBody'],
                               'icon' => $row['firstIcon'],
                               'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
                       ),
                       'last_post' => array(
                               'id' => $row['ID_LAST_MSG'],
                               'member' => array(
                                       'name' => $row['lastPosterName'],
                                       'id' => $row['ID_LAST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
                                       'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
                               ),
                               'time' => timeformat($row['lastPosterTime']),
                               'timestamp' => forum_time(true, $row['lastPosterTime']),
                               'subject' => $row['lastSubject'],
                               'preview' => $row['lastBody'],
                               'icon' => $row['lastIcon'],
                               'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
                       ),
                       'new' => $row['isRead'],
                       'new_from' => $row['new_from'],
                       'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
                       'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
                       'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
                       'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
                       'is_locked' => !empty($row['locked']),
                       'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
                       'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
                       'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
                       'is_posted_in' => false,
                       'icon' => $row['firstIcon'],
                       'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                       'subject' => $row['firstSubject'],
                       'pages' => $pages,
                       'replies' => $row['numReplies'],
                       'views' => $row['numViews'],
                       '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>'
                       )
               );

               determineTopicClass($topics[$row['ID_TOPIC']]);
       }
       mysql_free_result($request);

       if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
       {
               $result = db_query("
                       SELECT ID_TOPIC
                       FROM {$db_prefix}messages
                       WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
                               AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
               while ($row = mysql_fetch_assoc($result))
               {
                       if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
                       {
                               $topics[$row['ID_TOPIC']]['is_posted_in'] = true;
                               $topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
                       }
               }
               mysql_free_result($result);
       }

       }

if (!empty($topics))
   {
   echo '
       <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
           <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
               <tr>';

   echo '
                   <td class="titlebg" colspan="7">', $heading, '</td>';
   echo '
               </tr>';

   echo '
                               <tr class="titlebg">
                                       <td width="10%" colspan="2"> </td>
                                       <td>', $txt[70], '
                                       </td><td width="14%">', $txt[109], '
                                       </td><td width="4%" align="center">', $txt[110], '
                                       </td><td width="4%" align="center">', $txt[301], '
                                       </td><td width="24%">', $txt[111], '
                                       </td>
                               </tr>';

       foreach ($topics as $topic)
       {



ad_ctr = 0;
foreach ($topics as $topic)
{
ad_ctr += 1;
if (ad_ctr > 50)
{
ad_ctr = 1;
echo '<tr><td colspan="7">';

<script type="text/javascript"><!--
google_ad_client = "pub-2734280293205008";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
//2006-11-24: banner
google_ad_channel = "8428626223";
google_color_border = "CCCCCC";
google_color_bg = "CCCCCC";
google_color_link = "11593C";
google_color_text = "000000";
google_color_url = "063E3F";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

echo '</td></tr>';
}




               // Do we want to seperate the sticky and lock status out?
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

               echo '
                               <tr>
                                       <td class="windowbg2" valign="middle" align="center" width="6%">
                                               <img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
                                       </td><td class="windowbg2" valign="middle" align="center" width="4%">
                                               <img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
                                       </td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
                                       if ($topic['new'] == 0)
                                               {
                                               echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
                                               }
                                       echo '
                                       <span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
                                       <td class="windowbg2" valign="middle" width="14%">
                                               ', $topic['first_post']['member']['link'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['replies'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['views'], '</td>
                                       <td class="windowbg2" valign="middle" width="22%">
                                               <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
                                               <span class="smalltext">
                                                       ', $topic['last_post']['time'], '<br />
                                                       ', $txt[525], ' ', $topic['last_post']['member']['link'], '
                                               </span>
                                       </td>
                               </tr>';
       }

   echo '</table></div>';

   }
       else
           echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


I get the error message:

Parse error: parse error, unexpected '=' in /mounted-storage/home4/sub002/sc11940-GNVW/overunity/Sources/Load.php(1736) : eval()'d code(35) : eval()'d code on line 245

Did I insert it wrongly ?
Many thanks.
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 30, 2007, 11:57:45 PM
You need to 'echo' that out so that script text itself ends up in the generated page.

Try changing:
<script type="text/javascript"><!--
to:
echo '<script type="text/javascript"><!--

And change:
</script>
to:
</script>';
Title: Re: "recent topics" in SMF style
Post by: hartiberlin on July 31, 2007, 07:54:14 AM
I only got it to work,
when I used:
$ad_ctr
instead of
ad_ctr

So is it not a variable, which have to be declared ??

( P.S: I am a newbie,when it comes to PHP...)
Title: Re: "recent topics" in SMF style
Post by: jacortina on July 31, 2007, 01:35:36 PM
Yes. My mistake. Variables need the '$', so it should have been $ad_ctr all along.
Title: Re: "recent topics" in SMF style
Post by: jpark on August 03, 2007, 03:40:50 AM
I'm wondering if this can be done easily...I would like to use this recent topics list and incorporate a drop-down menu where you can select which board you want to see the recent topics from.  Could anyone offer some suggestions?
Title: Re: "recent topics" in SMF style
Post by: jacortina on August 04, 2007, 12:51:39 AM
I guess that depends on what you mean by 'easily done'. ;)

It also depends on what you mean by 'this recent topics list'. There's a couple of different code sets here.

Generally, though, it could be done by 'scavenging' the code in Display.template.php which generates the 'Jump To:' box and tweak it to self-reference the article page with an argument indicating the chosen board (but don't use "board=##").
Title: Re: "recent topics" in SMF style
Post by: jpark on August 04, 2007, 07:38:51 AM
oh, sorry... I was using your code here http://www.tinyportal.net/index.php?topic=596.150
would self-referencing work in a block as well or only in an article page?  haha.. i guess for me, it wouldn't be "easily done"
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 05, 2007, 02:38:35 AM
jpark take a looksy.

http://www.tinyportal.net/index.php?topic=17909.0
Title: Re: "recent topics" in SMF style
Post by: Rus on August 17, 2007, 05:22:37 PM
Thank you for this, Today I decided I wanted something like this and bang, here it is.
Title: Re: "recent topics" in SMF style
Post by: Rus on August 24, 2007, 03:25:44 AM
Hello,

I changed the code on the first page just a little for formatting purposes and now for some reason if you click the new button it goes to the first post and if you click the topic link it goes to where the new button should take you.  I have no idea why.  Could anyone pick out whatever it is that I am missing here?  Thank you.

global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor"> ';
       $what=ssi_recentTopics('8', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: pelhrimak on September 07, 2007, 06:01:49 PM
Hello, please How to do recent topic from only these boards?

'41','48','46','8','49','10','52','9','11','47','53'
Title: Re: "recent topics" in SMF style
Post by: IchBin on September 07, 2007, 06:29:34 PM
Please read through the posts pelhrimak, instructions have already been given in other threads as well.
Title: Re: "recent topics" in SMF style
Post by: pelhrimak on September 07, 2007, 08:50:59 PM
I don´t understand you :( I need only recent posts from these boards, when I add '41','48','46','8','49','10','52','9','11','47','53' I watch all recent post without postsm which are in boards ('41','48','46','8','49','10','52','9','11','47','53')
Title: Re: "recent topics" in SMF style
Post by: Rus on September 07, 2007, 08:54:33 PM
I still havent gotten around to fixing my error here but maybe this weekend I'll have some time to try and figure it out.

On the other hand if someone more experienced where able to pull it out of there and let me know that would be great.
Title: Re: "recent topics" in SMF style
Post by: catchpen on September 09, 2007, 03:33:29 AM
Most excellent work on this topic. I just read all 33 pages :uglystupid2:.  I have 1 question, how hard would it be to show (not interact but just view) the stars that the SMF mod "Topic Ratings" mod gives on each topic? Is this a possibility?

Link to SMF mod

http://www.simplemachines.org/community/index.php?topic=25023.0

The only columns needed is the subject, around 200 characters of the body of post and the rating stars...

Thanks in advance!
Title: Re: "recent topics" in SMF style
Post by: IchBin on September 09, 2007, 04:34:20 AM
Well considering that none of us wrote that mod, I don't think anyone could give you the proper answer.
Title: Re: "recent topics" in SMF style
Post by: dannbass on September 16, 2007, 02:16:05 AM
I got a question... where should I put the b in between the < > or if I want the new messages to be bold?

>echo '<a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
This is the code I'm using... or do you have any other suggestions?

Thanks!
Title: Re: "recent topics" in SMF style
Post by: IchBin on September 16, 2007, 03:56:12 AM
The line you posted is for the new.gif graphic if there are any new messages. You can use < b > or < strong > but make sure you use it on the right line. :)
Title: Re: "recent topics" in SMF style
Post by: dannbass on September 16, 2007, 05:15:32 PM
That might be it... ;D

I've been trying all morning with no luck, could you please help me out?

// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg" valign="middle" align="center" width="4%">
<img src="' . $topic['last_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg2' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';


This is the part that I need to alter, but don't see where to stick the < b >
Thanks!!
Title: Re: "recent topics" in SMF style
Post by: IchBin on September 16, 2007, 08:14:32 PM
Can you show me which snippet you're using, as i don't think that is the code either. All of that code is for the creation of the different images such as sticky, locked, new.gif etc.
Title: Re: "recent topics" in SMF style
Post by: dannbass on September 16, 2007, 08:26:45 PM
Sure! Thanks!
This is the code I'm using...

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings;

if (empty($settings['number_recent_posts']))
$number_recent_posts = 15;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';

}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';

}
else
{
$limit_clause = 'LIMIT ' . $list_count;

}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;

}

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
    WHERE " . $where_clause . "
    AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
ORDER BY t.ID_LAST_MSG DESC " . $limit_clause, __FILE__, __LINE__);


$topics = array();
$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '‚ « ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '‚ « ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ‚ »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . $row['firstPosterName'] . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . $row['lastPosterName'] . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                 
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg" valign="middle" align="center" width="4%">
<img src="' . $topic['last_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg2' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg" valign="middle" width="12%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg2" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="20%">

<div align=right><span class="smalltext">
', $topic['last_post']['time'], '<br />
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
', $txt[525], ' ', $topic['last_post']['member']['link'], '



</span></div>
</td>
</tr>';
}

    echo '</table></div>';

    }
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 16, 2007, 08:45:43 PM
Find:
</td><td class="windowbg2' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}


Replace with:
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '';
if ($topic['new'] == 0)
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
Title: Re: "recent topics" in SMF style
Post by: dannbass on September 16, 2007, 08:53:08 PM
Fabulous!!!! Thanks a lot!!! :up:
Title: Re: "recent topics" in SMF style
Post by: bebu on September 19, 2007, 12:35:41 AM
Quote from: dannbass on September 16, 2007, 08:26:45 PM
Sure! Thanks!
This is the code I'm using...

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings;

if (empty($settings['number_recent_posts']))
$number_recent_posts = 15;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';

}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';

}
else
{
$limit_clause = 'LIMIT ' . $list_count;

}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;

}

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
    WHERE " . $where_clause . "
    AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
ORDER BY t.ID_LAST_MSG DESC " . $limit_clause, __FILE__, __LINE__);


$topics = array();
$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '‚ « ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '‚ « ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ‚ »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . $row['firstPosterName'] . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . $row['lastPosterName'] . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg" valign="middle" align="center" width="4%">
<img src="' . $topic['last_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg2' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], ' ', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg" valign="middle" width="12%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg2" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="20%">

<div align=right><span class="smalltext">
', $topic['last_post']['time'], '<br />
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
', $txt[525], ' ', $topic['last_post']['member']['link'], '



</span></div>
</td>
</tr>';
}

    echo '</table></div>';

    }


Hi,
where can I change the number of recent topics in this code?
I cant find it, pls help.
THX and greetings
Bebu
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 19, 2007, 12:53:19 AM
That code is meant to be used in an article. Articles are accessed using a URL in the form like "...index.php?page=##". This code looks for additional parameters, one of which is 'count'. "...index.php?page=##;count=50" will show the most recent 50 topics.

Go to this message: http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580 to see the code with extensive somments about usage.

It does note that you can use the code in a block, but it gives information about what variables have to be hard-coded to allow for that.
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on October 23, 2007, 03:43:58 AM
I'm still using this for my main front page, but looks like there has been quite a bit of conversation since I was here last. Is there a new/better/updated version from what I'm using?


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block)
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert these lines and those below next section
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

        $dummy = array();
        $dummy[] = $row['ID_FIRST_MEMBER'];
        $dummy[] = $row['ID_LAST_MEMBER'];
        loadMemberData($dummy);
        $profile_first = &$user_profile[$row['ID_FIRST_MEMBER']];
        $profile_last = &$user_profile[$row['ID_LAST_MEMBER']];

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $profile_first['member_group_color'] . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $profile_last['member_group_color'] . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:-4px;"' : 'style="margin:-4px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


Thanks in advance!
Title: Re: "recent topics" in SMF style
Post by: jacortina on October 23, 2007, 03:58:56 AM
The code in this message:
http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580

will use less calls (and potentially fewer DB queries). It also allows the specification of boards to be unconditionally excluded.

But no other enhanced capabilties or extra options have been added.
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on October 23, 2007, 04:02:46 AM
Not sure if it's simply the time of day in which I'm testing my site (due to shared resources) but it seems to load a bit quicker with this new code.

Thanks!
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on October 23, 2007, 04:09:18 AM
Hmmm, I'm having the same problem I did before ... If a page spans multiple pages, it shows up as "Ã,« 1 2 Ã,»". I just removed the three instances of Ã, in the code. What is the purpose of that character?
Title: Re: "recent topics" in SMF style
Post by: jacortina on October 23, 2007, 04:16:13 AM
There is none. It snuck into the posted code at some point.

I've gone back and edited them out of the posted code (which I swear, I've done before).
Title: Re: "recent topics" in SMF style
Post by: dannbass on October 23, 2007, 03:31:26 PM
Hi J.A.Cortina!
I have a question that I think might not be appropriate here... I posted it a couple of days ago here (http://www.tinyportal.net/index.php?topic=19512.msg159330#msg159330), but I realized the problem is not the multi-tabs, because today I was trying the same thing with the accordion style menu (http://www.tinyportal.net/index.php?topic=19485.msg159623#msg159623) and it worked up to three times...

Any idea why I'm not able to have multiple blocks or more than three blocks?
Anything will be very appreciated!
Title: Re: "recent topics" in SMF style
Post by: jacortina on October 23, 2007, 03:38:56 PM
Hold on for a few days. I'm looking at implementing a version of this as a separate function. While not as 'convenient' as having it in a block/article, it makes a LOT more sense when its functionality will be called in more than one place/circumstance.

And when your block is down to a few arguments assignments and a function call for each iteration, it might be easier to  track down problems (if that alone doesn't clear it up).
Title: Re: "recent topics" in SMF style
Post by: dannbass on October 23, 2007, 03:45:21 PM
Thanks a lot!! As always I'm very grateful!! I'll wait as long as it takes!
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on October 23, 2007, 09:39:47 PM
Is it possible to add a message stating that you need to register if a guest is viewing?

Thanks
Title: Re: "recent topics" in SMF style
Post by: catchpen on November 03, 2007, 11:25:04 PM
Sorry if this already been covered - long thread here.

I have this code on my front page, but I'm kinda doing a workaround for what I really need. 

I created a board with duplicate posts from around the forum just so I can show the selected posts with this code on the front page and still have the RSS available (workaround for me not being a coder). 

Well I installed the mod that added "Return a single post <?php ssi_grabMessage(); ?>" on my SSI.php 1.1 allows me to select select only certain posts.

How hard is it or even possible to use this "ssi_grabMessage();" with this code to select around 15 single posts instead of selecting whole boards?

here's the version I'm using:

lobal $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
       $exclude_boards = array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','18','19','20','22','23','24');      // KEEP (to preserve variable declaration)
//      $exclude_boards = array(5);     //  Exclude single board
//      $exclude_boards = array(5, 8);  //  Exclude multiple boards
       $ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//


       $do_query = 1;

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
//      Comment out the Info Center's Most Recent Posts Code and Insert this
//      to show Most Recent Topics in full detail style instead
//
      $list_count = 15;
      $heading = 'Latest 15  Picks';
      $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * max($list_count, 5));
      $limit_clause = 'LIMIT ' . $list_count;
      $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////


       $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
       $icon_sources = array();
       foreach ($stable_icons as $icon)
               $icon_sources[$icon] = 'images_url';

       $groupcolors = array();
       $request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
       while ($row = mysql_fetch_assoc($request))
               $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
       mysql_free_result($request);

       $topics = array();

       if ($do_query == 1)
       {
       $request = db_query("
               SELECT
                               ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
                               t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
                               ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
                               IFNULL(meml.realName, ml.posterName) AS lastPosterName,
                               mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
                               ml.subject AS lastSubject, b.memberGroups,
                               ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
                               LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
                               ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
                               . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
                       FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
                               LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
                               LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
                       WHERE " . $where_clause . $ex_board_clause . "
                               AND t.ID_TOPIC = ms.ID_TOPIC
                               AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
                               AND ms.ID_MSG = t.ID_FIRST_MSG
                               AND ml.ID_MSG = t.ID_LAST_MSG
                               AND " . $user_info['query_see_board'] . "
                       ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


       $topic_ids = array();
       while ($row = mysql_fetch_assoc($request))
       {
               if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
                       continue;

               $topic_ids[] = $row['ID_TOPIC'];

               // Clip the strings first because censoring is slow :/. (for some reason?)
               $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
               if (strlen($row['firstBody']) > 128)
                       $row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
               $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
               if (strlen($row['lastBody']) > 128)
                       $row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

                       $row['lastSubject'] = $row['firstSubject'];
                       $row['lastBody'] = $row['firstBody'];

               // Decide how many pages the topic should have.
               $topic_length = $row['numReplies'] + 1;
               if ($topic_length > $modSettings['defaultMaxMessages'])
               {
                       $tmppages = array();
                       $tmpa = 1;
                       for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
                       {
                               $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
                               $tmpa++;
                       }
                       // Show links to all the pages?
                       if (count($tmppages) <= 5)
                               $pages = 'ÂÃ,« ' . implode(' ', $tmppages);
                       // Or skip a few?
                       else
                               $pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

                       if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
                               $pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
                       $pages .= ' ÂÃ,»';
               }
               else
                       $pages = '';

               // We need to check the topic icons exist... you can never be too sure!
               if (empty($modSettings['messageIconChecks_disable']))
               {
                       // First icon first... as you'd expect.
                       if (!isset($icon_sources[$row['firstIcon']]))
                               $icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
                       // Last icon... last... duh.
                       if (!isset($icon_sources[$row['lastIcon']]))
                               $icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
               }

               $color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
               $color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

               // And build the array.
               $topics[$row['ID_TOPIC']] = array(
                       'id' => $row['ID_TOPIC'],
                       'first_post' => array(
                               'id' => $row['ID_FIRST_MSG'],
                               'member' => array(
                                       'name' => $row['firstPosterName'],
                                       'id' => $row['ID_FIRST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
                                       'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
                               ),
                               'time' => timeformat($row['firstPosterTime']),
                               'timestamp' => forum_time(true, $row['firstPosterTime']),
                               'subject' => $row['firstSubject'],
                               'preview' => $row['firstBody'],
                               'icon' => $row['firstIcon'],
                               'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
                       ),
                       'last_post' => array(
                               'id' => $row['ID_LAST_MSG'],
                               'member' => array(
                                       'name' => $row['lastPosterName'],
                                       'id' => $row['ID_LAST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
                                       'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
                               ),
                               'time' => timeformat($row['lastPosterTime']),
                               'timestamp' => forum_time(true, $row['lastPosterTime']),
                               'subject' => $row['lastSubject'],
                               'preview' => $row['lastBody'],
                               'icon' => $row['lastIcon'],
                               'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
                       ),
                       'new' => $row['isRead'],
                       'new_from' => $row['new_from'],
                       'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
                       'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
                       'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
                       'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
                       'is_locked' => !empty($row['locked']),
                       'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
                       'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
                       'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
                       'is_posted_in' => false,
                       'icon' => $row['firstIcon'],
                       'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                       'subject' => $row['firstSubject'],
                       'pages' => $pages,
                       'replies' => $row['numReplies'],
                       'views' => $row['numViews'],
                       '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>'
                       )
               );

               determineTopicClass($topics[$row['ID_TOPIC']]);
       }
       mysql_free_result($request);

       if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
       {
               $result = db_query("
                       SELECT ID_TOPIC
                       FROM {$db_prefix}messages
                       WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
                               AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
               while ($row = mysql_fetch_assoc($result))
               {
                       if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
                       {
                               $topics[$row['ID_TOPIC']]['is_posted_in'] = true;
                               $topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
                       }
               }
               mysql_free_result($result);
       }

       }

if (!empty($topics))
   {
   echo '
       <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
           <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
               <tr>';

   echo '
                   <td class="titlebg" colspan="7">', $heading, '</td>';
   echo '
               </tr>';

   echo '
                               <tr class="titlebg">
                                       <td width="10%" colspan="2"> </td>
                                       <td>', $txt[70], '
                                       </td><td width="14%">', $txt[109], '
                                       </td><td width="4%" align="center">', $txt[110], '
                                       </td><td width="4%" align="center">', $txt[301], '
                                       </td><td width="24%">', $txt[111], '
                                       </td>
                               </tr>';

       foreach ($topics as $topic)
       {
               // Do we want to seperate the sticky and lock status out?
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

               echo '
                               <tr>
                                       <td class="windowbg2" valign="middle" align="center" width="6%">
                                               <img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
                                       </td><td class="windowbg2" valign="middle" align="center" width="4%">
                                               <img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
                                       </td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
                                       if ($topic['new'] == 0)
                                               {
                                               echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
                                               }
                                       echo '
                                       <span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
                                       <td class="windowbg2" valign="middle" width="14%">
                                               ', $topic['first_post']['member']['link'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['replies'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['views'], '</td>
                                       <td class="windowbg2" valign="middle" width="22%">
                                               <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
                                               <span class="smalltext">
                                                       ', $topic['last_post']['time'], '<br />
                                                       ', $txt[525], ' ', $topic['last_post']['member']['link'], '
                                               </span>
                                       </td>
                               </tr>';
       }

   echo '</table></div>';

   }
       else
           echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


THanks for the help.
C.P.
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 03, 2007, 11:35:15 PM
This can give you 15 specific Topics. This is just what's done when you use this for 'Global (Topic) Announcements'. I've taken the lates code and pared it down to what's need to use it that way.

Put the topic numbers you want in the $announce_topics array and put what you want for the $heading:
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

$exclude_boards = array(); // KEEP (to preserve variable declaration)
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
$do_query = 1;

$announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
$heading = '<center>Announcements<center>';

$where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
$limit_clause = '';
$order_clause = 't.ID_LAST_MSG DESC';


$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group, mems.ID_POST_GROUP as mems_pgroup,
ml.subject AS lastSubject, b.memberGroups, meml.ID_POST_GROUP as meml_pgroup,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . ( !empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']])  ? '<font color="'. ( !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : $groupcolors[$row['mems_pgroup']] ) . '">' : '' ) : '' )  . $row['firstPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']]))) ? '</font>' : '' ) . '</a>' ) : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['lastPosterName'] . '">' . (!empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]) ? '<font color="'. ( !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : $groupcolors[$row['meml_pgroup']] ) .'">' : '' ) : '' ) . $row['lastPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]))) ? '</font>' : '' ) . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '';
if ($topic['new'] == 0)
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';
Title: Re: "recent topics" in SMF style
Post by: catchpen on November 04, 2007, 08:19:03 AM
Wow thanks JA Cortina, that works perfectly! I have to say I'm pretty amazed of the of the reply time too, We went out to eat, came back, and my problem was solved, thanks a million. That will get rid of my deliberate double posting.   :up:

This is a bit off topic but is there anyway to get an RSS output from this? I've searched around but no luck so far.

THanks,
C.P.
Title: Re: "recent topics" in SMF style
Post by: jacortina on November 05, 2007, 02:25:31 AM
The answers come quicker (and are a LOT easier ) when the coding for the request is already in place. ;)

There's no RSS output from this. Among my current projects is re-working this code, though, and I'll look at that. But it won't come in the immediate future (got a bunch of things I'm working on at the moment).
Title: Re: "recent topics" in SMF style
Post by: catchpen on November 05, 2007, 03:12:14 AM
OK, many thanks for the customized version, this code is good enough as is :)
Title: Re: "recent topics" in SMF style
Post by: kgw on November 26, 2007, 12:06:15 AM
This was the only thing that ha(D) completely ticked me off about tinyportal.  I am doing a new domain and decided to give tinyportal a try. I would stick this code in the next update.
Nice job and thanks!

BTW, I have found TP very easy to use. Now maybe my admins will get off there butts!
Title: Re: "recent topics" in SMF style
Post by: growl on December 08, 2007, 03:16:33 PM
Is there a way to display only the posts of the past ten days or so?
And, furthermore, is there a cssstyled version of that mode, too?
Title: Re: "recent topics" in SMF style
Post by: dannbass on December 14, 2007, 09:21:37 PM
Hi!
I've been toying with the widths of my blocks and realize that would be a nice addition to this "recent topics" block if the topic titles could be abbreviated and have the mouseover for the complete title.
Just a thought!
Title: Re: "recent topics" in SMF style
Post by: IchBin on December 15, 2007, 01:06:05 AM
abbreviate the title? How would you do that? lol
Title: Re: "recent topics" in SMF style
Post by: dannbass on December 15, 2007, 04:49:09 PM
Maybe I didn't write it with the proper php name...  :'( you know, with the ['short_subject'] that you can say how many letters it can have, just as the recent topics that TP has built in. :)
Title: Re: "recent topics" in SMF style
Post by: IchBin on December 15, 2007, 07:49:14 PM
String limit is totally different than Abbreviate.
Title: Re: "recent topics" in SMF style
Post by: dannbass on December 15, 2007, 10:16:57 PM
Ok, thanks... any ideas on how to implement the string limit into this block?
Title: Re: "recent topics" in SMF style
Post by: IchBin on December 15, 2007, 11:40:34 PM
The shorten_subject array variable didn't work?
Title: Re: "recent topics" in SMF style
Post by: dannbass on December 16, 2007, 12:12:04 AM
There is none in the last code that J.A.Cortina created...
Title: Re: "recent topics" in SMF style
Post by: jacortina on December 16, 2007, 12:25:32 AM
Right. Because, as the thread title notes, this code was designed specifically to present recent topics in SMF Style.

But you do want to use the 'shorten_subject()' function;

Try find all occurrences of:
$row['firstSubject']

And replace them with:
shorten_subject($row['firstSubject'], 25)
Title: Re: "recent topics" in SMF style
Post by: dannbass on December 16, 2007, 05:44:30 PM
Yes you are right, I just wanted to be able to use this function as well.
Thanks for taking the time again!!
Title: Re: "recent topics" in SMF style
Post by: pelhrimak on December 21, 2007, 06:05:58 PM
Hi I am using this code, but I have a problem

-> http://www.tinyportal.net/index.php?topic=20823.0
Title: Re: "recent topics" in SMF style
Post by: IchBin on December 21, 2007, 07:00:14 PM
Please follow the rules here and DO NOT cross post. Your issue will be dealt with when someone has something to say. Now, please go read the other post and actually give us some info about your setup etc.
Title: Re: "recent topics" in SMF style
Post by: mrzcn on December 22, 2007, 01:55:53 PM
how can i remove "am pm"  at time format ?
Title: Re: "recent topics" in SMF style
Post by: jacortina on December 22, 2007, 02:16:52 PM
That's a Forum setting specified in the Forum's Admin Control Panel. It's the same throughout.
Title: Re: "recent topics" in SMF style
Post by: mrzcn on December 22, 2007, 05:07:06 PM
yes i correct it.in forums time seems without am pm.but i see in the block still :S
Title: Re: "recent topics" in SMF style
Post by: jacortina on December 22, 2007, 05:22:12 PM
My mistake, that should be using the individual USER'S perferred time format as set in their profile. It's calling the standard timeformat() function (in SMF's Subs.php) which, in turn, uses $user_info['time_format'].

So, if it's showing something for you other than the way the forum is set, please verify what your personal settings are in your profile's 'Look and Layout' section.
Title: Re: "recent topics" in SMF style
Post by: dannbass on December 22, 2007, 05:51:45 PM
Quote from: J.A.Cortina on October 23, 2007, 03:38:56 PM
Hold on for a few days. I'm looking at implementing a version of this as a separate function. While not as 'convenient' as having it in a block/article, it makes a LOT more sense when its functionality will be called in more than one place/circumstance.

I don't mean to sound pushy or anything like it... but how is the progress? and what did you mean by having it as a separate function? like using it in a template, instead that in TinyPortal, and then having the a block with a simple command?

Thanks a lot!
Title: Re: "recent topics" in SMF style
Post by: jacortina on December 22, 2007, 06:05:55 PM
Like the ssi_recentTopics() is a separate function which can echo things out or return an array.

Personally, I use this code in a couple of spots (in an article with URL query arguments to put out different 'recent' lists, but also in a block with specific topic ID's set to act as a 'Global Announcement' block). So, rather than maintain code in multiple places, a single function can be called with only the argmument list to be dealt with.

I think I'm on the last bit of tweaking/major debugging, so I should be able to put it out soon.

In your case, with wanting to have a block with multiple instances of it, it would be a lot easier to:

set up args;
call function;

set up args;
call function;

set up args;
call function;

Rather than repeat the whole code block each time.
Title: Re: "recent topics" in SMF style
Post by: dannbass on December 22, 2007, 06:13:30 PM
Thanks! I thought of that... at least in theory, but not in practice... the other day I thought that why will I need to repeat the same whole code every time... but I need more practice with my php skills...

Thanks a lot! I really appreciate all the work that you have put into it!
Title: Re: "recent topics" in SMF style
Post by: mrzcn on December 22, 2007, 09:59:42 PM
yes it solved
thank you so much :)
Title: Re: "recent topics" in SMF style
Post by: catchpen on December 23, 2007, 02:21:57 AM
Here's a version that incorporates the "Topic Rating" mod at SMF http://www.simplemachines.org/community/index.php?topic=25023.0 (http://www.simplemachines.org/community/index.php?topic=25023.0)
This must be installed first for this to work.  It shows the rating stars of each topic in a column instead of number of views. 
First try so let me know if there is anything wrong with code  ;)

$announce_topics = array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ); // Topic ID's to be 'Announced' is where you put the topic ID #'s


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

$exclude_boards = array(); // KEEP (to preserve variable declaration)
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
$do_query = 1;

$announce_topics = array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ); // Topic ID's to be 'Announced'
$heading = '<center> Latest Picks <center>';

$where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
$limit_clause = '';
$order_clause = 't.ID_LAST_MSG DESC';


$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies,rating,ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group, mems.ID_POST_GROUP as mems_pgroup,
ml.subject AS lastSubject, b.memberGroups, meml.ID_POST_GROUP as meml_pgroup,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . ( !empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']])  ? '<font color="'. ( !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : $groupcolors[$row['mems_pgroup']] ) . '">' : '' ) : '' )  . $row['firstPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']]))) ? '</font>' : '' ) . '</a>' ) : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['lastPosterName'] . '">' . (!empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]) ? '<font color="'. ( !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : $groupcolors[$row['meml_pgroup']] ) .'">' : '' ) : '' ) . $row['lastPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]))) ? '</font>' : '' ) . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'rating' => array(
'empty' => $row['rating'] == -1,
'whole' => (int) ($row['rating'] / 2),
'half' => $row['rating'] % 2
),
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="2%" colspan="1"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center"> Rating
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>


<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="54%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '';
if ($topic['new'] == 0)
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="8%" align="center">';
if ($topic['rating']['empty'] == 1)
echo 'N/A';
else
{
for ($i = 0; $i < $topic['rating']['whole']; $i++)
echo '<img src="', $settings['images_url'], '/star.gif" alt="*" border="0" />';
//!!! Should have a half star!
if (!empty($topic['rating']['half']))
echo '<img src="', $settings['images_url'], '/star.gif" alt="*" border="0" />';
}
echo '
</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';



Click on my www for example.  :up:
Title: Re: "recent topics" in SMF style
Post by: jacortina on January 09, 2008, 07:20:39 PM
OK. Finally got around to some shakedown use of this and I think it's ready for release.

Below is the function for generating Recent Topics in SMF (and other) format along with snippets for its use in blocks or an article. Additionally, the function can return the recent topics array for whatever use you might want to put it to.

As mentioned upthread and elsewhere, I've implemented this as a function in order to avoid having the same code stored over and over in the TP blocks/articles tables. If you're only going to use one instance of the code (in one article only or in one block only), you can certainly include it in the block or article. Just paste the code from the function (excluding the <? php and ?> at top/bottom) at the end of the block/article.

At the moment, the sample block and article codes are set up to load the function from the file 'JAC_Functions.php' in the forum's Sources directory. But as long as you change where it's looking, you can place it where you want. You could, if you wished, paste just the function part in your SSI.php, as others have done with custom functions (I'd rather not do this as any restore/upgrade will end up getting rid of it).

Put in a php article (no title or frame):
global $scripturl, $sourcedir, $user_info;

$func_location = $sourcedir . '/JAC_Functions.php';

if (!function_exists('JAC_RecentTopics'))
if (file_exists($func_location)) require_once($func_location);
if (!function_exists('JAC_RecentTopics')) {
echo 'Could not find the desired recent topics function.';
return;}

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
//
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on your topic notify list (Admin can specify user besides self) -OR-
// most recent XX topics on your topic bookmarks list (Admin can specify user besides self) -OR-
// most recent XX topics started by you (Admin can specify user besides self)
//
// All in the detailed topic format (Like SMF's View Unread Topics - with or without paging)*
// -OR- Minimal side block recent topics
//  -OR-    Brief, single line format
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to $modSettings['defaultMaxTopics']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to $modSettings['defaultMaxTopics']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// index.php?page=##;type=bookmark or index.php?page=##;type=bookmark;count=50
// Topics in the bookmark list up to number
// specified in 'count' or a maximum of 100 topics.    REQUIRES Bookmark Mod
//
// *** Admins Only ***
// index.php?page=##;type=bookmark;user=XXX or index.php?page=##;type=bookmark;user=XXX;count=50
// Topics in the bookmark list of specified user up to number
// specified in 'count' or a maximum of 100 topics.    REQUIRES Bookmark Mod
//
// index.php?page=##;type=started or index.php?page=##;type=started;count=50
// Topics started by current user list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
// Topics started by specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument 'create' to sort by topic creation sequence (most recent first)
// rather than by last reply sequence
//
//  Add style=              fullblock - Full SMF detail format suitable for center blocks
// full      - Full SMF detail format with paging, column sort - ARTICLE ONLY
// condensed - Minimal Info Multiline Recent Topics sutable for side blocks
// line      - Minimal Info Single Line Recent Topics sutable for side/center blocks
//
// Unconditional Restrictions (only most restrictive given will be used):
//  Add excludes=#,#,#,#,#; Boards whose Topics are NOT to be listed. (least restrictive)
//  Add includes=#,#,#,#,#; Only boards whose Topics ARE to be listed.
//  Add topics=#,#,#,#,#; Only Topics which ARE to be listed. (most restrictive)
//

if ($user_info['is_guest']) {
echo 'Please <a href="', $scripturl, '?action=login"><u>Login</u></a> or <a href="', $scripturl, '?action=register"><u>Register</u></a> to view.';
}

//==========================================================================================================================

$default_type = 'last';
$default_excludes = array();
$default_style = 'fullblock';
$default_colors = 'Y';

$parm = array();

$parm['type'] = strtolower($default_type);
if (isset($_GET['type'])) $parm['type'] = strtolower($_GET['type']);

if (isset($_GET['count'])) $parm['count'] = strtolower($_GET['count']);

$select_array = 'X';
$select_array = array();
if (isset($_GET['topics'])) {
$parm['select_array'] = explode(',',$_GET['topics']);
$parm['array_type'] = 'T'; }
elseif (isset($_GET['includes'])) {
$parm['select_array'] = explode(',',$_GET['includes']);
$parm['array_type'] = 'I'; }
elseif (isset($_GET['excludes'])) {
$parm['select_array'] = explode(',',$_GET['excludes']);
$parm['array_type'] = 'X'; }
else {
$parm['select_array'] = $default_excludes;
$parm['array_type'] = 'X'; }

$parm['style'] = strtolower($default_style);
if (isset($_GET['style'])) $parm['style'] = strtolower($_GET['style']);

if (isset($_GET['create'])) $parm['sort_by_start'] = true;

if (isset($_GET['user'])) $parm['user_id'] = strtolower($_GET['user']);

if (isset($_GET['start'])) $parm['start_num'] = strtolower($_GET['start']);

if (isset($_GET['sort'])) $parm['sort_col'] = strtolower($_GET['sort']);

if (isset($_GET['asc']) || isset($_GET['ASC'])) $parm['sort_dir'] = 'asc';
if (isset($_GET['desc']) || isset($_GET['DESC'])) $parm['sort_dir'] = 'desc';

$parm['mem_colors'] = (strtoupper($default_colors) == 'Y') ? true : false;
if (isset($_GET['colors'])) $parm['mem_colors'] = true;

$parm['save_url_stub'] =  '?page='.$_GET['page'] .
                 ( isset($_GET['type']) ? ';type='.$_GET['type'] : '' ) .
                 ( isset($_GET['count']) ? ';count='.$_GET['count'] : '' ) .
                 ( isset($_GET['excludes']) ? ';excludes='.$_GET['excludes'] : '' ) .
                 ( isset($_GET['includes']) ? ';includes='.$_GET['includes'] : '' ) .
                 ( isset($_GET['topics']) ? ';topics='.$_GET['topics'] : '' ) .
                 ( isset($_GET['create']) ? ';create' : '' ) .
                 ( isset($_GET['user']) ? ';user='.$_GET['user'] : '' ) .
                 ( isset($_GET['style']) ? ';style='.$_GET['style'] : '' ) .
                 ( isset($_GET['colors']) ? ';colors' : '' );

echo '<div class="windowbg3">';
$topics = JAC_RecentTopics($parm, 'echo');
echo '</div>';

In an article, all parameters are supplied via URL query arguments. If you do an article preview, it will show using default values only. You can manually edit the URL to try out some of the available options like each of the different format styles.

I believe that this is backward compatible to earlier incarnations in that using existing URL argument lists with this new article (as long as the function file is in place) will yield compatible output EXCEPT in the matter where no 'count' parameter was specified. Previous versions used the forum's 'recent posts to show on board index' and this now uses the forum's 'topics to show per page'.


Put in a phpbox block (no title or frame):
global $settings, $user_info, $modSettings, $sourcedir;

$func_location = $sourcedir . '/JAC_Functions.php';
if (!function_exists('JAC_RecentTopics'))
if (file_exists($func_location)) require_once($func_location);
if (!function_exists('JAC_RecentTopics')) {
echo 'Could not find the desired recent topics function.';
return;}

// JAC_RecentTopics(
//
// $parm['type'] = 'last' // 'last'      - Most Recently Posted To Topics - # equal to $count argument (default)
// 'hours'     - Most Recently Posted To Topics - During laste number of hours equal to $count argument
// 'notify'    - Most Recently Posted To Topics User is Being Notified On (Watched Topics)
// 'bookmark'  - Most Recently Posted To Topics User has Bookmarked (requires Bookmark Mod)
// 'started'   - Most Recently Posted To Topics Started by User
// 'unreplied' - Most Recently Started Topics with Zero Replies.
//
// $parm['count'] = 0, // Number of Topics to show of the above types (except type=hours where it's the # of hours back to list from)
//   specify 0 (zero) to default to $modSettings['defaultMaxTopics'] (Topics to show per page), or 24
//   hours for $type='hours'
//
// $parm['array_type'] = 'X', // 'X' - Following array is of boards to exclude
// 'I' - Following array is of only boards to include
// 'T' - Following array is of only Topics to show
// $parm['select_array'] = array(),
//
// $parm['style'] = 'fullblock', //  'fullblock' - Full SMF detail format suitable for center blocks
//  'condensed' - Minimal Info Multiline Recent Topics sutable for side blocks (like TP's Recent)
//  'line'      - Minimal Info Single Line Recent Topics suitable for side/center blocks
//
// $parm['heading'] = '', // Text to put in the Table 'heading' area to label the block/box.
// leave empty to let function generate, specify 'SUPPRESS' for no heading area
//
// $parm['height'] = 0, // Height for blocks of styles 'line' and 'condensed'
// overflow: auto will casue scrollbar.
//
// $parm['mem_colors'] = true, // Output Poster names in Membergroup Colors
//
// $parm['sort_by_start'] = false, // Alter sort behavior to be by topic start date/time, ascending
//   (most useful for $type='started')


//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
// $parm['heading'] = '<center>Announcements<center>';
// $parm['array_type'] = 'T';
// $parm['select_array'] = array(1457, 2793, 2900, 2906, 2941, 3177, 3222);  // These are Topics that will be shown
////////////////////////////////////////////

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
// $parm['heading'] = 'Most Recently Posted To Topics You Started';
// $parm['type'] = 'started';
// $parm['count'] = 5;
////////////////////////////////////////////

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $parm['count'] = $settings['number_recent_posts'];
// $parm['heading'] = 'Most Recently Posted To Topics';
////////////////////////////////////////////

// $parm['type'] = 'last';
// $parm['count'] = 0;
// $parm['array_type'] = 'X';
// $parm['select_array'] = array();
// $parm['style'] = 'fullblock';
// $parm['heading'] = '';
// $parm['height'] = 0;
// $parm['mem_colors'] = true;
// $parm['sort_by_start'] = false;

//-----------------------------------
$parm = array();

$parm['count'] = 10;
$parm['style'] = 'condensed';
$parm['height'] = 100;

JAC_RecentTopics($parm, 'echo');
//-----------------------------------

Defaults will be used for any and all parameters not explicitly supplied. So just supply those you need and call the function.

The 'fullblock' style won't work at all well with left or right blocks and the 'condensed' won't look right in the center. The 'line' style can work in either.


Because of post size limits, I'll attach the function file here and post it to the next message
Title: Re: "recent topics" in SMF style
Post by: jacortina on January 09, 2008, 07:21:21 PM
And, finally, the function itself:
<?php

function JAC_RecentTopics($parm = array(), $output 'echo')
{
    global 
$context$settings$scripturl$txt$db_prefix$ID_MEMBER$user_info$modSettings$user_profile$options;
    
$do_query 1;

    
$valid_recent_types = array('last''unreplied''hours''notify''bookmark''started');
    
$valid_array_types = array('X''I''T');
    
$valid_out_styles = array('fullblock''full''condensed''line'); 
    
$valid_sorts = array('last_post''subject''starter''replies''views''first_post');
    
$sort_dirs = array(
        
'last_post' => array('DESC''asc'),
        
'subject' => array('ASC''desc'),
        
'starter' => array('ASC''desc'),
        
'replies' => array('ASC''desc'),
        
'views' => array('ASC''desc'),
        
'first_post' => array('ASC''desc'),
    );

    
$output strtolower($output) != 'array' 'echo' 'array';

    if (!
is_array($parm)) {
        if (
$output 'array') {
            return array();}
        else {
            echo 
'Unexpected argument - expecting parameter array)';
            return; }
    }

if(!empty($options['num_topics_page']))
$modSettings['defaultMaxTopics'] = $options['num_topics_page'];
if(!empty($options['num_posts_page']))
$modSettings['defaultMaxMessages'] = $options['num_posts_page'];

    
$parm['type'] = (isset($parm['type']) && !empty($parm['type']) && in_array(strtolower($parm['type']), $valid_recent_types)) ? strtolower($parm['type']) : $valid_recent_types[0];

    
$parm['count'] = (isset($parm['count']) && !empty($parm['count']) && is_numeric($parm['count'])) ? $parm['count'] : 0;

    
$parm['array_type'] = (isset($parm['array_type']) && !empty($parm['array_type']) && in_array(strtoupper($parm['array_type']), $valid_array_types)) ? strtoupper($parm['array_type']) : $valid_array_types[0];

    
$parm['select_array'] = (isset($parm['select_array']) && !empty($parm['select_array']) && is_array($parm['select_array'])) ? $parm['select_array'] : array();

    
$parm['style'] = (isset($parm['style']) && !empty($parm['style']) && in_array(strtolower($parm['style']), $valid_out_styles)) ? strtolower($parm['style']) : $valid_out_styles[0];

    
$parm['heading'] = (isset($parm['heading'])) ? $parm['heading'] : '';

    
$parm['sort_by_start'] = (isset($parm['sort_by_start']) && ($parm['sort_by_start'] === true)) ? true false;

    
$parm['user_id'] = (isset($parm['user_id']) && !empty($parm['user_id']) && is_numeric($parm['user_id'])) ? $parm['user_id'] : 0;
    
$parm['user_id'] = $parm['user_id'] != $parm['user_id'] : $ID_MEMBER;

    
$parm['start_num'] = (isset($parm['start_num']) && !empty($parm['start_num']) && is_numeric($parm['start_num'])) ? $parm['start_num'] : 0;

    
$parm['sort_col'] = (isset($parm['sort_col']) && !empty($parm['sort_col']) && in_array(strtolower($parm['sort_col']), $valid_sorts)) ? strtolower($parm['sort_col']) : $valid_sorts[0];

    
$parm['sort_dir'] = (isset($parm['sort_dir']) && ((strtoupper($parm['sort_dir']) == 'ASC') || (strtoupper($parm['sort_dir']) == 'DESC'))) ? strtoupper($parm['sort_dir']) : '';
    
$cur_dir $parm['sort_dir'] != '' $parm['sort_dir'] : $sort_dirs[$parm['sort_col']];

    
$parm['save_url_stub'] = (isset($parm['save_url_stub'])) ? $parm['save_url_stub'] : '';

    
$parm['mem_colors'] = (isset($parm['mem_colors']) && ($parm['mem_colors'] === false)) ? false true;

    
$parm['height'] = (isset($parm['height'])) ? $parm['height'] : 0;

    
$parm['per_page'] = (isset($parm['per_page']) && !empty($parm['per_page']) && is_numeric($parm['per_page'])) ? $parm['per_page'] : 0;
    
$parm['per_page'] = $parm['per_page'] > $parm['per_page'] : $modSettings['defaultMaxTopics'];

    
$constraint '';
    if (
$parm['type'] == 'bookmark')
if( mysql_num_rowsmysql_query("SHOW TABLES LIKE '"$db_prefix"bookmarks'") ) == )
            
$parm['type'] == 'notify';

    if ((
$parm['type'] == 'bookmark') || ($parm['type'] == 'notify')) {
    
$watched_topics = array();
        if (
$parm['type'] == 'bookmark')
        
$request db_query("SELECT ID_TOPIC FROM {$db_prefix}bookmarks WHERE ID_MEMBER = {$parm['user_id']}"__FILE____LINE__);
        if (
$parm['type'] == 'notify')
        
$request db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$parm['user_id']} AND ID_BOARD = 0"__FILE____LINE__);
    
while ($row mysql_fetch_assoc($request))
            
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
if (count($watched_topics) == 0)
$do_query 0;
    
else
    
$constraint =' t.ID_TOPIC IN (' implode(', '$watched_topics) . ')';
    }

    
$type_methods = array(
        
'last' =>   ($parm['array_type'] == 'X' ? (($parm['count'] != 0) ? ('t.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - (150 max($parm['count'], $parm['per_page'])))) : '1' ) : '1'),
        
'unreplied' => 't.numReplies = 0',
        
'hours' => $parm['count'] == 'ml.posterTime >= ' strtotime('1 day ago') : 'ml.posterTime >= ' strtotime($parm['count'] . ' hours ago'),
        
'notify' => $constraint,
        
'bookmark' => $constraint,
        
'started' => 't.ID_MEMBER_STARTED = ' $parm['user_id'],
    );
    
$type_method_clause $type_methods[$parm['type']];

    
$select_methods = array(
        
'X' => count($parm['select_array']) == '' ' AND b.ID_BOARD NOT IN (' implode(', '$parm['select_array']) . ')',
        
'I' => count($parm['select_array']) == '' ' AND b.ID_BOARD IN (' implode(', '$parm['select_array']) . ')',
        
'T' => count($parm['select_array']) == '' ' AND t.ID_TOPIC IN (' implode(', '$parm['select_array']) . ')',
    );
    
$select_method_clause $select_methods[$parm['array_type']];

    
$sort_methods = array(
    
'last_post' => ($parm['sort_by_start'] ? 't.ID_FIRST_MSG' 't.ID_LAST_MSG'),
    
'subject' => 'ms.subject',
    
'starter' => 'IFNULL(mems.realName, ms.posterName)',
    
'replies' => 't.numReplies',
    
'views' => 't.numViews',
    
'first_post' => 't.ID_TOPIC',
    );
    
$sort_method_clause ' ORDER BY '$sort_methods[$parm['sort_col']] . ' ' . ($parm['sort_dir'] == '' $sort_dirs[$parm['sort_col']][0] : $parm['sort_dir']);

    
$type_heading = array(
   
    'last' => 'Most Recently Posted To Topics',
       
'unreplied' => 'Unreplied To Topics',
        
'hours' => 'Topics Posted To In Last '. ($parm['count'] == 24 $parm['count']) . ' Hours',
        
'notify' => 'Topics Being Watched' . ($ID_MEMBER == $parm['user_id'] ? '' : (' by User# ' $parm['user_id'])),
        
'bookmark' => 'Topics Bookmarked' . ($ID_MEMBER == $parm['user_id'] ? '' : (' by User# ' $parm['user_id'])),
        
'started' => 'Topics Started ' . ($ID_MEMBER == $parm['user_id'] ? ' by You' : (' by User# ' $parm['user_id'])),
    );

$limit_clause $parm['type'] == 'hours' '' : ($parm['count'] == ' LIMIT '.$modSettings['defaultMaxTopics'] : ' LIMIT '.$parm['count']);

$stable_icons = array('xx''thumbup''thumbdown''exclamation''question''lamp''smiley''angry''cheesy''grin''sad''wink''moved''recycled''wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$groupcolors = array();
        if (
$parm['mem_colors']) {
    
$request db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups"__FILE____LINE__);
     while ($row mysql_fetch_assoc($request))
     $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
    
mysql_free_result($request);
    
}

        if (
$parm['style'] == 'full') {
$request db_query("
SELECT b.ID_BOARD
FROM 
{$db_prefix}boards AS b
WHERE " 
$user_info['query_see_board'] . (!empty($modSettings['recycle_enable']) && ($modSettings['recycle_board'] > 0) ? "
AND b.ID_BOARD != " 
. (int) $modSettings['recycle_board'] : '') .
$select_method_clause,
__FILE____LINE__);
    
$boards = array();
    
while ($row mysql_fetch_assoc($request))
    
$boards[] = $row['ID_BOARD'];
    
mysql_free_result($request);
    
$query_this_board = empty($boards) ? '' 'WHERE t.ID_BOARD IN (' implode(', '$boards) . ')';

    $request db_query("
    SELECT COUNT(*), MIN(t.ID_LAST_MSG)
       FROM 
{$db_prefix}topics AS t, {$db_prefix}messages AS ml " .
$query_this_board "
AND ml.ID_MSG = t.ID_LAST_MSG " 
.
$select_method_clause "
AND " 
$type_method_clause,
__FILE____LINE__);
    
list ($num_topics$min_message) = mysql_fetch_row($request);
    
mysql_free_result($request);
            
$limit_clause 'LIMIT ' $parm['start_num'] . ', ' $parm['per_page'];
        }

$query "
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group, mems.ID_POST_GROUP as mems_pgroup,
ml.subject AS lastSubject, b.memberGroups, meml.ID_POST_GROUP as meml_pgroup,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
ml.body AS lastBody, ms.body AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from'
) . "
FROM (
{$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN 
{$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN 
{$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " 
$type_method_clause " " .
    $select_method_clause " " .
   "AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD " 
.
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > " AND b.ID_BOARD != $modSettings[recycle_board]'') .
   " AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " 
$user_info['query_see_board'] . " " .
$sort_method_clause " " $limit_clause;

$request db_query($query__FILE____LINE__);

$topic_ids = array();
while ($row mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '')));

if ($row['ID_FIRST_MSG'] == $row['ID_LAST_MSG'])
{
$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];
}
        else
        {
    $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '')));
        }

// Decide how many pages the topic should have.
$topic_length $row['numReplies'] + 1;
if ($topic_length $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa 1;
for ($tmpb 0$tmpb $topic_length$tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.' $tmpb ';topicseen">' $tmpa '</a>';
$tmpa++;
}

// Show links to all the pages?
if (count($tmppages) <= 5)
$pages '« ' implode(' '$tmppages);
// Or skip a few?
else
$pages '« ' $tmppages[0] . ' ' $tmppages[1] . ' ... ' $tmppages[count($tmppages) - 2] . ' ' $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length $modSettings['enableAllMessages'])
$pages .= '  <a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0;all">' $txt[190] . '</a>';
$pages .= ' Â»';
}
else
$pages '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['firstIcon'] . '.gif') ? 'images_url' 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['lastIcon'] . '.gif') ? 'images_url' 'default_images_url';
}

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl '?action=profile;u=' $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? ('<a href="' $scripturl '?action=profile;u=' $row['ID_FIRST_MEMBER'] . '" title="' $txt[92] . ' ' $row['firstPosterName'] . '">' . ( $parm['mem_colors'] ? ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']])  ? '<font color="'. ( !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : $groupcolors[$row['mems_pgroup']] ) . '">' '' ) : '' )  . $row['firstPosterName'] . (( $parm['mem_colors'] && ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']]))) ? '</font>' '' ) . '</a>' ) : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true$row['firstPosterTime']),
'subject' => $row['firstSubject'],
'short_subject' => shorten_subject($row['firstSubject'], 25),
'preview' => shorten_subject($row['firstBody'],128),
'body' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' $row['firstIcon'] . '.gif',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0;topicseen">' $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl '?action=profile;u=' $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' $scripturl '?action=profile;u=' $row['ID_LAST_MEMBER'] . '" title="' $txt[92] . ' ' $row['lastPosterName'] . '">' . ( $parm['mem_colors'] ? ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]) ? '<font color="'. ( !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : $groupcolors[$row['meml_pgroup']] ) .'">' '' ) : '' ) . $row['lastPosterName'] . (( $parm['mem_colors'] && ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]))) ? '</font>' '' ) . '</a>' $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true$row['lastPosterTime']),
'subject' => $row['lastSubject'],
'short_subject' => shorten_subject($row['lastSubject'], 25),
'preview' => shorten_subject($row['lastBody'],128),
'body' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' $row['lastIcon'] . '.gif',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . ';topicseen#msg' $row['ID_LAST_MSG'],
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . ';topicseen#msg' $row['ID_LAST_MSG'] . '">' $row['lastSubject'] . '</a>'
),
'new' => !$row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl '?topic=' $row['ID_TOPIC'] . '.msg' $row['new_from'] . ';topicseen#new',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['new_from']) . ';topicseen' . ($row['numReplies'] == '' 'new'),
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['new_from']) . ';topicseen#msg' $row['new_from'] . '">' $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result db_query("
SELECT ID_TOPIC
FROM 
{$db_prefix}messages
WHERE ID_TOPIC IN (" 
implode(', '$topic_ids) . ")
AND ID_MEMBER = 
$ID_MEMBER"__FILE____LINE__);
while ($row mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if ($output == 'array')
    return $topics;

if ( ($parm['style'] == 'full') || ($parm['style'] == 'fullblock') )
{
if (!empty($topics))
    {

    if ($parm['style'] == 'full') {
        $page_url $parm['save_url_stub'] . ';sort=' $parm['sort_col'] . ( ($parm['sort_dir'] != '') ? ';'.$parm['sort_dir'] : '');
        $current_page = (int) $parm['start_num'] / $parm['per_page'];
        $links = array(
            'first' => $parm['start_num'] >= $parm['per_page'] ? $scripturl $page_url ';start=0' '',
            'prev' => $parm['start_num'] >= $parm['per_page'] ? $scripturl .  $page_url ';start=' . ($parm['start_num'] - $parm['per_page']) : '',
            'next' => $parm['start_num'] + $parm['per_page'] < $num_topics $scripturl .  $page_url ';start=' . ($parm['start_num'] + $parm['per_page']) : '',
            'last' =>  ( ($parm['start_num'] + $parm['per_page']) < $num_topics) ? ($scripturl .  $page_url ';start=' . (floor(($num_topics 1) / $parm['per_page']) * $parm['per_page']) ) : '',
            'up' => $scripturl,
        );
        
$page_info = array(
            'current_page' => floor($parm['start_num'] / $parm['per_page']) + 1,
        
    'num_pages' => floor(($num_topics 1) / $parm['per_page']) + 1,
                    
'page_index' => constructPageIndex($scripturl $parm['save_url_stub'] . ';sort=' $parm['sort_col'] . ( ($parm['sort_dir'] != '') ? ';'.$parm['sort_dir'] : ''), $parm['start_num'], $num_topics$parm['per_page'], false),
        );

            
echo '
                 <table border="0" width="100%" cellpadding="0" cellspacing="0">
                  <tr>
                  <td class="middletext" valign="middle">' 
$txt[139] . ': ' $page_info['page_index'] . '</td>
                 </tr>
                 </table>'
;
    }

    echo '
        <div class="tborder" '
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' 'style="margin:0px;"''>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">'
;


if ($parm['heading'] != 'SUPPRESS') {
    
echo '
<tr>'
;
echo '
<td class="titlebg" colspan="7">'
, ($parm['heading'] == '' $type_heading[$parm['type']] : $parm['heading']), '</td>';
echo '
</tr>'
;
}

    if ($parm['style'] == 'fullblock') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>'
$txt[70], '
</td><td width="14%">'
$txt[109], '
</td><td width="4%" align="center">'
$txt[110], '
</td><td width="4%" align="center">'
$txt[301], '
</td><td width="24%">'
$txt[111], '
</td>
</tr>'
;
    }

    if ($parm['style'] == 'full') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>
<a href="'
$parm['save_url_stub'], ';sort=subject', ($parm['sort_col'] != 'subject' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'subject') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="14%">
    <a href="'
$parm['save_url_stub'], ';sort=starter', ($parm['sort_col'] != 'starter' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'starter') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="4%" align="center">
    <a href="'
$parm['save_url_stub'], ';sort=replies', ($parm['sort_col'] != 'replies' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'replies') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="4%" align="center">
    <a href="'
$parm['save_url_stub'], ';sort=views', ($parm['sort_col'] != 'views' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'views') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="24%">
    <a href="'
$parm['save_url_stub'], ';sort=last_post', ($parm['sort_col'] != 'last_post' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'last_post') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td>
</tr>'
;
    }

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' 
$settings['images_url'] . '/topic/' $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' 
$topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' 
$topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' '' '" width="48%" valign="middle">' $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' 
$settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' '' $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' 
$settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' '';
if ($topic['new'])
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="'$topic['new_href'], '"> <img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="'$txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
  echo '
<span class="smalltext">'
$topic['pages'], '<br>'$txt['smf88'], ' '$topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
'
$topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
'
$topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
'
$topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="'
$topic['last_post']['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="'$txt[111], '" title="'$txt[111], '" style="float: right;" /></a>
<span class="smalltext">
'
$topic['last_post']['time'], '<br />
'
$txt[525], ' '$topic['last_post']['member']['link'], '
</span>
</td>
</tr>'
;
}

    echo '</table>';

    echo '</div>';

    if ($parm['style'] == 'full') {

            
echo '
                 <table border="0" width="100%" cellpadding="0" cellspacing="0">
                  <tr>
                  <td class="middletext" valign="middle">' 
$txt[139] . ': ' $page_info['page_index'] . '</td>
                 </tr>
                 </table>'
;

    echo'
<div class="tborder"><div class="titlebg2">
<table cellpadding="8" cellspacing="0" width="55%">
<tr>
<td align="left" style="padding-top: 2ex;" class="smalltext">'
, !empty($modSettings['enableParticipation']) ? '
<img src="' 
$settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' $txt['participation_caption'] . '<br />' '''
<img src="' 
$settings['images_url'] . '/topic/normal_post.gif" alt="" align="middle" /> ' $txt[457] . '<br />
<img src="' 
$settings['images_url'] . '/topic/hot_post.gif" alt="" align="middle" /> ' $txt[454] . '<br />
<img src="' 
$settings['images_url'] . '/topic/veryhot_post.gif" alt="" align="middle" /> ' $txt[455] . '
</td>
<td align="left" valign="top" style="padding-top: 2ex;" class="smalltext">
<img src="' 
$settings['images_url'] . '/icons/quick_lock.gif" alt="" align="middle" /> ' $txt[456] . '<br />' . ($modSettings['enableStickyTopics'] == '1' '
<img src="' 
$settings['images_url'] . '/icons/' . (!empty($settings['seperate_sticky_lock']) ? 'quick_sticky' 'normal_post_sticky') . '.gif" alt="" align="middle" /> ' $txt['smf96'] . '<br />' '') . ($modSettings['pollMode'] == '1' '
<img src="' 
$settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' $txt['smf43'] : '') . '
</td>
</tr>
</table>
</div>'
;
    }

    }
else
    

    
echo '<b><u>',($parm['heading'] == '' $type_heading[$parm['type']] : $parm['heading']),'<br><br>No Topics Match Search Criteria</u></b>';
    }
}

if ($parm['style'] == 'condensed')
{
$counter=1$cmax=count($topics);
$height_clause = (isset($parm['height']) && ($parm['height'] > 0) ? ' height: '.$parm['height'].'px;' '');
echo ' <div style="width: 100%;'$height_clause' overflow: auto;">
<div class="windowbg" style="width: 100%; overflow: hidden;">'
;
foreach ($topics as $w)
{
echo '
<div class="smalltext"><a href="'
.$w['last_post']['href'].'">'. ($w['new'] ? '<b>' '') . $w['last_post']['short_subject'] . ($w['new'] ? '</b>' '') .'</a></div>
<div class="smalltext">'
$txt[525], ' <b>'$w['last_post']['member']['link'], '</b> ';
if($w['new'])
echo '<a href="'.$w['new_href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '</div><div class="smalltext">';
echo '['.$w['last_post']['time'].']
</div>'
;

if($counter != $cmax)
echo '<hr />';
$counter++;
}
echo '
</div></div>'
;
}

if ($parm['style'] == 'line')
{
$counter=1$cmax=count($topics);
$height_clause = (isset($parm['height']) && ($parm['height'] > 0) ? ' height: '.$parm['height'].'px;' '');
echo ' <div style="width: 100%;'$height_clause' overflow: auto;">
<div class="windowbg" style="width: 100%; overflow: hidden;">'
;
foreach ($topics as $w)
{
echo '<div class="windowbg'. ((($counter 2) == 0) ? '' '2') . '" style="width: 100%;line-height: 1.4em">';
echo '
<span class="smalltext"><a href="'
.$w['last_post']['href'].'">'. ($w['new'] ? '<b>' '') . $w['last_post']['subject'] . ($w['new'] ? '</b>' '') .'</a>  </span>
<span class="smalltext">(in '
.$w['board']['link'].')  </span>
<span class="smalltext">'
$txt[525], ' <b>'$w['last_post']['member']['link'], '</b>  </span>
<span class="smalltext">'
;
if($w['new'])
echo '<a href="'.$w['new_href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '['.$w['last_post']['time'].']
</span><br />'
;

$counter++;
echo '
</div>'
;
}
echo '
</div></div>'
;
}

}

?>
Title: Re: "recent topics" in SMF style
Post by: dannbass on January 09, 2008, 10:49:43 PM
Wow! Thank you very much! I'm speechless!
It is just what I needed, again thank you for all the work!
Title: Re: "recent topics" in SMF style
Post by: gffb on January 21, 2008, 07:49:28 AM
I have been looking through this topic and it nearly does what I would like the only thing I cant seem to find is how to make a block just show unread topics ie NEW like this index.php?action=unread
Title: Re: "recent topics" in SMF style
Post by: G6Cad on January 21, 2008, 08:12:24 AM
More or less the built in recent topics block do just that.
Title: Re: "recent topics" in SMF style
Post by: gffb on January 21, 2008, 08:16:12 AM
Yes but that shows recent ie last few posts which some you might of viewed but other you might not so they will still be classed and maked as new but be further down you recent topics block, I was thinking of a block that only showed unread posts so u can keep track or posts that u have not read.
Title: Re: "recent topics" in SMF style
Post by: G6Cad on January 21, 2008, 08:32:11 AM
Then i think you mean ALL unred messages ?
like this /index.php?action=unread;all;start=0
Title: Re: "recent topics" in SMF style
Post by: gffb on January 21, 2008, 08:33:46 AM
Yes I would like that info and only that info (unread) in a block left/right can it be done?
Title: Re: "recent topics" in SMF style
Post by: Jpg on January 31, 2008, 08:03:41 PM
I needed this for a theme I'm making.
Thanks Bloc. :D
Title: Re: "recent topics" in SMF style
Post by: catchpen on February 03, 2008, 06:53:59 AM
Could someone with coding knowledge please help?

I removed the column on the left end to show if it's a hot or very hot topic to declutter my TP page. I thought I did it right but i keep getting errors in my log and it seems to coincide with viewing the front page -

"8: Undefined index: is_hot
File: /home/xxxxx/public_html/topsupplementshops/Sources/Subs.php
Line: 3125"

I'm assuming that I left something in the block i should have taken out?
here's my recent topics SMF style block code

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

$exclude_boards = array(); // KEEP (to preserve variable declaration)
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
$do_query = 1;

$announce_topics = array( 415, 410, 403, 375, 343, 262, 177, 306, 413, 237, 274, 362, 293, 396 ); // Topic ID's to be 'Announced'
$heading = '<center> Latest Picks <center>';

$where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
$limit_clause = '';
$order_clause = 't.ID_LAST_MSG DESC';


$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies,rating,ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group, mems.ID_POST_GROUP as mems_pgroup,
ml.subject AS lastSubject, b.memberGroups, meml.ID_POST_GROUP as meml_pgroup,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . ( !empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']])  ? '<font color="'. ( !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : $groupcolors[$row['mems_pgroup']] ) . '">' : '' ) : '' )  . $row['firstPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']]))) ? '</font>' : '' ) . '</a>' ) : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['lastPosterName'] . '">' . (!empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]) ? '<font color="'. ( !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : $groupcolors[$row['meml_pgroup']] ) .'">' : '' ) : '' ) . $row['lastPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]))) ? '</font>' : '' ) . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,

'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'rating' => array(
'empty' => $row['rating'] == -1,
'whole' => (int) ($row['rating'] / 2),
'half' => $row['rating'] % 2
),
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))

mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="2%" colspan="1"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', Rating, '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>


<td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="54%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '';
if ($topic['new'] == 0)
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="8%" align="center">';
if ($topic['rating']['empty'] == 1)
echo 'N/A';
else
{
for ($i = 0; $i < $topic['rating']['whole']; $i++)
echo '<img src="', $settings['images_url'], '/star.gif" alt="*" border="0" />';
//!!! Should have a half star!
if (!empty($topic['rating']['half']))
echo '<img src="', $settings['images_url'], '/star.gif" alt="*" border="0" />';
}
echo '
</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';



Thanks the help is appreciated.
Title: Re: "recent topics" in SMF style
Post by: IchBin on February 03, 2008, 05:56:37 PM
The error has nothing to do with your code you posted.
Title: Re: "recent topics" in SMF style
Post by: catchpen on February 03, 2008, 06:08:57 PM
Ok thanks, just a coincidence I guess.

So it's an SMF thing?
Title: Re: "recent topics" in SMF style
Post by: IchBin on February 03, 2008, 07:14:30 PM
Its possibly another mod or something.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on February 06, 2008, 03:35:35 AM
i think there is a nice way to show recent post in center block like phpfusion one
http://www.phpfusion-themes.com/news.php   

hope someones can make it for tpblock in smf.
Title: Re: "recent topics" in SMF style
Post by: catchpen on February 06, 2008, 10:20:55 AM
Quote from: alhaudhie on February 06, 2008, 03:35:35 AM
i think there is a nice way to show recent post in center block like phpfusion one
http://www.phpfusion-themes.com/news.php   

hope someones can make it for tpblock in smf.

Good thing it ain't a rattlesnake  :laugh:
Title: Re: "recent topics" in SMF style
Post by: Innocenzia on March 03, 2008, 10:42:31 AM
Hi everyone,

Type=started is what I've been looking for, however i want all my users to be able to see their own, as it is now only the "Admin" can see it, and I can't figure out how to get it to work for the members as well, as it is now everyone is going to ask me to check their threads for them, and it's going to drive me insane.

I'm now using the one J.A.Cortina has posted on page 38. Is it possible to make started viewable for all members?
Title: Re: "recent topics" in SMF style
Post by: failquail on April 07, 2008, 01:10:12 PM
Is there a way to make it actually mark topics as read when clicked?

This is for the first code block.
Title: Re: "recent topics" in SMF style
Post by: IchBin on April 07, 2008, 03:11:24 PM
If you refresh the page does the list of topics change/update?
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on April 13, 2008, 03:30:59 PM
how can i remove msg icon?
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi111.photobucket.com%2Falbums%2Fn148%2Falhaudhie%2Ficon.jpg&hash=b37b0f152f89d05c1a911d33c95454951f5b4e37)
Title: Re: "recent topics" in SMF style
Post by: 2inchpvc on April 14, 2008, 09:17:49 AM
I used the code from below for this block and tried the board specific code given, but it still lists from EVERY board not just the ones specified, is there something I am doing wrong?? Plus if I remove the "NULL," it works but the background for it dissapears.




  global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="0" cellpadding="4">
                               <tr>
    <td colspan="3" class="titlebg">Recently Posted To Topics (see Forum for more!!)</td>
  </tr> ';
       $what=ssi_recentTopics('15', NULL, array('30','1','11','2','41','53','3','51','54','37','4','10','7','12','14','5','33','34','36','32','35','40','20','18','6','15','21','22','23','24'));


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))

                echo '
                                                <span class="smalltext3">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

Title: Re: "recent topics" in SMF style
Post by: IchBin on April 14, 2008, 11:14:20 PM
The boards you put in there are boards you want to exclude.
Title: Re: "recent topics" in SMF style
Post by: 2inchpvc on April 15, 2008, 12:56:42 AM
Quote from: IchBinâ,,¢ on April 14, 2008, 11:14:20 PM
The boards you put in there are boards you want to exclude.

But it doesn't work unless you remove the "NULL" and then when you do that you lose the background for the block.  ????
Title: Re: "recent topics" in SMF style
Post by: 2inchpvc on April 16, 2008, 03:51:36 PM
Quote from: 2inchpvc on April 15, 2008, 12:56:42 AM
Quote from: IchBinâ,,¢ on April 14, 2008, 11:14:20 PM
The boards you put in there are boards you want to exclude.

But it doesn't work unless you remove the "NULL" and then when you do that you lose the background for the block.  ????

bump
Title: Re: "recent topics" in SMF style
Post by: IchBin on April 16, 2008, 04:23:15 PM
You are using the function wrong. Where you put null, is where you should have the array of boards that you want to exclude.
ssi_recentTopics(15, array(1,2,3,4,5,9,15), 'array')
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on April 30, 2008, 04:17:10 PM
Quote from: alhaudhie on February 06, 2008, 03:35:35 AM
i think there is a nice way to show recent post in center block like phpfusion one
http://www.phpfusion-themes.com/news.php   

hope someones can make it for tpblock in smf.

anybody can do this?
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on July 07, 2008, 05:15:28 AM
(https://www.tinyportal.net/index.php?action=dlattach;topic=596.0;attach=14495;image)

how can we add category name before the subject like smf default one?
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 07, 2008, 02:15:13 PM
I can't see what you're talking about. The picture is too small.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on July 07, 2008, 04:24:52 PM
Quote from: IchBinâ,,¢ on July 07, 2008, 02:15:13 PM
I can't see what you're talking about. The picture is too small.

The original code for this topic only show
Topic Subject-Poster Name-Date

But how can we add category name before the topic subject like the default smf recent post.
Title: Re: "recent topics" in SMF style
Post by: b33znutz on July 08, 2008, 04:48:36 AM
Quote from: alhaudhie on July 07, 2008, 04:24:52 PM
Quote from: IchBinâ,,¢ on July 07, 2008, 02:15:13 PM
I can't see what you're talking about. The picture is too small.

The original code for this topic only show
Topic Subject-Poster Name-Date

But how can we add category name before the topic subject like the default smf recent post.

that is what i came here for this time! just want to add a category(boardname) row....

UPDATE:
i did it myself... added "board name" column .. (i totally guessed!!)   O0

click to enlarge
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg.b33znet.info%2Fimages%2F3babfmccqzx99ad1hi7_thumb.jpg&hash=00a52f9ccd85d65da69de56e20a020f52e1de8a9) (http://img.b33znet.info/viewer.php?file=3babfmccqzx99ad1hi7.jpg)

       

       
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="6" class="titlebg">Recent Posts</td></tr> ';
       $what=ssi_recentTopics('4', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="10%">
                                                ', $topic['poster']['link'], '
                                        </td>

                                        </td>
                                        <td class="windowbg" valign="middle" width="10%">
                                                ', $topic['board']['link'], '
                                        </td>


                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

Title: Re: "recent topics" in SMF style
Post by: IchBin on July 08, 2008, 05:20:28 AM
Why not just use ssi_recentTopics(); then?
Title: Re: "recent topics" in SMF style
Post by: b33znutz on July 08, 2008, 05:30:04 AM
Quote from: IchBinâ,,¢ on July 08, 2008, 05:20:28 AM
Why not just use ssi_recentTopics(); then?

no offense ich, but the question was "how" ... which would lead me to believe that the poster didnt know what they were doing. which would lead me to beleive that the poster wouldnt know about ssi_ stuff... i dont.. i just looked at the source and messed with it until it worked.. only took about 15mins to figure it out.....

just my thoughts.....
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 08, 2008, 05:34:32 AM
Well I assumed since the poster said they wanted it to look like SMF's that they knew about SMF's stuff. If the don't know what ssi is, then a quick search here and at SMF will bring up the answer.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on July 08, 2008, 06:02:56 AM
 :up:

Nice interaction and nice job.. thanks all...
Title: Re: "recent topics" in SMF style
Post by: b33znutz on July 08, 2008, 03:53:57 PM
Quote from: IchBinâ,,¢ on July 08, 2008, 05:34:32 AM
Well I assumed since the poster said they wanted it to look like SMF's that they knew about SMF's stuff. If the don't know what ssi is, then a quick search here and at SMF will bring up the answer.
seriously, no offense bro! just tryin to help.. most of the posts are 1+ years old and some of us are need some help this year, so i try...
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 08, 2008, 04:02:54 PM
No offense taken. But what is the difference between last years posts and this years? They are still relevant. Which is why we suggest a search. If the search is exhausted I don't mind helping out.
Title: Re: "recent topics" in SMF style
Post by: b33znutz on July 10, 2008, 01:12:39 AM
no difference.. just that some of the older posts dont get a lot of attention.. and it seems like the forum software craze that started a couple years back is coming to a slowdown, meaning not much active support (i know you guys do what you can when you can!!!!!!!)

no worries though... dont , all you guys (and the guys at smf) are the shit for all your FREE help for the n00bs!
Title: Re: "recent topics" in SMF style
Post by: b33znutz on July 10, 2008, 02:49:56 AM
i have this in a center block... center blocks show up on all pages.. is there a way to turn the center block off, for just the frontpage??
Title: Re: "recent topics" in SMF style
Post by: G6Cad on July 10, 2008, 08:47:05 AM
Depends on what version of TP you have installed, dont see that info from you.
In TP V098 No, you cant, in TP V01.0.5, Yes, you can turn them off.

In whole, giving support to you is somewhat a bit difficult, in one topic you say it's articles, and here you say it's the blocks ?   
Im a bit confused now  ???
Title: Re: "recent topics" in SMF style
Post by: b33znutz on July 10, 2008, 10:19:08 PM
Quote from: G6 on July 10, 2008, 08:47:05 AM
Depends on what version of TP you have installed, dont see that info from you.
In TP V098 No, you cant, in TP V01.0.5, Yes, you can turn them off.

oops, sorry. SMF 1.1.5 / TP 0.98
that answers that though. hmm.. perhaps i should upgrade....
for more info on my and my site, Click Here (http://www.tinyportal.net/index.php?topic=24897.msg200079#msg200079)

Quote from: G6 on July 10, 2008, 08:47:05 AM
In whole, giving support to you is somewhat a bit difficult, in one topic you say it's articles, and here you say it's the blocks ?  
Im a bit confused now  ???

articles? now im confused. i dont even use articles in tp or smf. perhaps you have me confused with someone else? i searched my posts and didnt find ANY with the WORD article in it. im sorry you think i am so difficult. guess its good i dont ask for much help! figure most of it out by myself, trial and error you know.. well, more error that trial, but it works...


Title: Re: "recent topics" in SMF style
Post by: G6Cad on July 10, 2008, 10:44:58 PM
Im not worried at all, and also, i didnt insult anyone, as i said, i were confused  ;)
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on July 14, 2008, 03:01:59 PM
one more thing..

how can we make New.gif image align to left (in same colum), not at the end of the topic?
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 14, 2008, 03:08:03 PM
Do you mean place the new.gif before the topic? Currently it is aligned left... I guess it depends on the way you look at it.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on July 14, 2008, 04:19:54 PM
Quote from: IchBinâ,,¢ on July 14, 2008, 03:08:03 PM
Do you mean place the new.gif before the topic? Currently it is aligned left... I guess it depends on the way you look at it.

nice suggest...

how can i make it before the topic?
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 14, 2008, 04:40:27 PM
Change this code:

                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';


To this:
                                        <td class="windowbg" valign="middle">';

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                                                echo $topic['link'];
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on July 14, 2008, 04:56:12 PM
yes..  :up:

one thing.. how can i make new.gif and the topic have a space... its now very closed...
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 14, 2008, 05:13:56 PM
Don't be afraid to try things alhaudie.
Add some spaces.
/>&nbsp;&nbsp;</a>';
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on July 21, 2008, 06:18:40 PM
i try to make recent topic for 40 posts.. but it still limit only for only 21
recentTopics('8', NULL, 'array');  i have change 8 to 40
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on July 29, 2008, 03:13:48 AM
Quote from: DASBEAN on October 23, 2007, 09:39:47 PM
Is it possible to add a message stating that you need to register if a guest is viewing?

Thanks

Just following up ... months later!

Thanks
Title: Re: "recent topics" in SMF style
Post by: Smoky on July 29, 2008, 03:31:06 AM
there should be a few codes or scripts around here for that ;)
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 29, 2008, 03:48:15 AM
To the last few posters..... WHAT code are you guys using? There is many different posts with many different code snippets. It would be better if each of you started your own topic and put your code and questions into your own topic.
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on July 30, 2008, 02:41:19 AM
My question was in response to the initial code posted on the first page of this thread. Basically just trying to figure out if a guest is visiting the site (currently no guests can read anything) that I'd like to display a message stating that you need to register ...

Thanks!
Title: Re: "recent topics" in SMF style
Post by: IchBin on July 30, 2008, 02:58:25 AM

if ($context['user']['is_guest'])
echo ' message to guest here in between these two single quotes';
else {
put all the code for recent topics here between the two curley braces.
}
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on July 31, 2008, 01:08:28 AM
Perfect, thanks Ich!
Title: Re: "recent topics" in SMF style
Post by: lyer on August 04, 2008, 09:47:06 AM
Quote from: b33znutz on July 08, 2008, 04:48:36 AM
Quote from: alhaudhie on July 07, 2008, 04:24:52 PM
Quote from: IchBinâ,,¢ on July 07, 2008, 02:15:13 PM
I can't see what you're talking about. The picture is too small.

The original code for this topic only show
Topic Subject-Poster Name-Date

But how can we add category name before the topic subject like the default smf recent post.

that is what i came here for this time! just want to add a category(boardname) row....

UPDATE:
i did it myself... added "board name" column .. (i totally guessed!!)   O0

click to enlarge
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg.b33znet.info%2Fimages%2F3babfmccqzx99ad1hi7_thumb.jpg&hash=00a52f9ccd85d65da69de56e20a020f52e1de8a9) (http://img.b33znet.info/viewer.php?file=3babfmccqzx99ad1hi7.jpg)

       

       
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="6" class="titlebg">Recent Posts</td></tr> ';
       $what=ssi_recentTopics('4', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="10%">
                                                ', $topic['poster']['link'], '
                                        </td>

                                        </td>
                                        <td class="windowbg" valign="middle" width="10%">
                                                ', $topic['board']['link'], '
                                        </td>


                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';



sir can i ask for  this code so icould put it in my forum?

by the way i using SMF 1.1.5 and TP v0.9.8

thanks....


Title: Re: "recent topics" in SMF style
Post by: IchBin on August 04, 2008, 06:00:56 PM
Isn't the code in your quote you just posted from him?
Title: Re: "recent topics" in SMF style
Post by: lyer on August 05, 2008, 07:34:40 AM
Quote from: IchBinâ,,¢ on August 04, 2008, 06:00:56 PM
Isn't the code in your quote you just posted from him?

what i mean is perfect code for my babylon theme

thanks
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on August 07, 2008, 04:27:58 PM
Can we put msg preview on mouseover in this code using js...?
Title: Re: "recent topics" in SMF style
Post by: Dragooon on August 07, 2008, 04:39:23 PM
Try this
global $scriptur, $modSettingsl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                <span title="',shorten_subject($topic['preview'], $modSettings['hoverLength']),'">', $topic['link'],'</span>';

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on August 07, 2008, 04:47:59 PM
Thanks.. very nice...

But how can we sett up to make show fastly...

other is i look in joomla, they have a msg preview with the title in the top and custom css.
Can we make like that?
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on August 07, 2008, 06:03:00 PM
can we make with with ajax than can refresh new topic automatically?
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 08, 2008, 12:35:08 AM
While you are at it Dragooon, can you make this serve up some Grilled Chicken Salad with some Ranch sause? I"m really hungry right now, and the salad sounds good about now.
Title: Re: "recent topics" in SMF style
Post by: Dragooon on August 08, 2008, 04:34:34 AM
Quote from: IchBinâ,,¢ on August 08, 2008, 12:35:08 AM
While you are at it Dragooon, can you make this serve up some Grilled Chicken Salad with some Ranch sause? I"m really hungry right now, and the salad sounds good about now.
Yeah sure, want some drinks too?

@alhaudie, The things you're asking will be requiring far more complexion in javascript than I know off. And IMHO, they are unneeded. There is no need for ajax to be there. It'll just end up increasing your server load.
Title: Re: "recent topics" in SMF style
Post by: hdhoran on August 09, 2008, 06:40:31 AM
I have a question......I decided to use this code:

Quote
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="6" class="titlebg">Recent Posts</td></tr> ';
       $what=ssi_recentTopics('15', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="10%">
                                                ', $topic['poster']['link'], '
                                        </td>

                                        </td>
                                        <td class="windowbg" valign="middle" width="10%">
                                                ', $topic['board']['link'], '
                                        </td>


                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

For my recent topics...but I was wondering if it were possible to keep the person who started the topic in the box instead of the last poster? We have a forum full of women who don't always get along, and them being able to avoid topics, boards and posters is a good thing sometimes.

And I swear, if you can show me...I'll be happy to provide the chicken salad with homemade ranch and drinks too.  :2funny:
Title: Re: "recent topics" in SMF style
Post by: dhighet on August 30, 2008, 10:52:02 PM
Is there a way to get this to work with "Member Color Link" http://custom.simplemachines.org/mods/index.php?mod=111
Title: Re: "recent topics" in SMF style
Post by: IchBin on August 30, 2008, 10:56:36 PM
The person who made the mod would most likely be the one to answer that.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on September 04, 2008, 05:09:38 PM
how can we made only just the topic and limit the topic character?

i dont want new icon,category,poster name,date.

Hope anybody can help.
Title: Re: "recent topics" in SMF style
Post by: G6Cad on September 04, 2008, 05:51:10 PM
Did you read through this entire thread ?
I think what you ask for is allready done, and that the code for it is in this thread.

Long read, but perhaps your lucky :)
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on September 04, 2008, 06:55:44 PM
Quote from: G6 on September 04, 2008, 05:51:10 PM
Did you read through this entire thread ?
I think what you ask for is allready done, and that the code for it is in this thread.

Long read, but perhaps your lucky :)

tq.. DONE.....

but one thing is i cant find it, how to limit the topic character?
Title: Re: "recent topics" in SMF style
Post by: IchBin on September 04, 2008, 07:17:23 PM
Did you use the search for that question? I'm pretty sure its been covered. Try searching for character limit and see what you find.
Title: Re: "recent topics" in SMF style
Post by: pedrox on September 18, 2008, 12:48:21 PM
Increase number pages on front page ?   :)
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on October 30, 2008, 05:04:43 AM
How can i add scrolling with this code

global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">
                               <tr><td colspan="6" class="titlebg" align="center">Kiriman Terbaru Di Forum    </td></tr> ';
       $what=ssi_recentTopics('12', NULL, 'array');


        foreach ($what as $topic)
        {
               echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                <span title="',shorten_subject($topic['preview'], $modSettings['hoverLength']),'">', $topic['link'],'</span>';

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="14%">
                                                ', $topic['poster']['link'], '
                                        </td>

                                        </td>
                                        <td class="windowbg" valign="middle" width="15%">
                                                ', $topic['board']['link'], '
                                        </td>


                                        <td class="windowbg2" valign="middle" width="27%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: IchBin on October 30, 2008, 02:08:52 PM
You add the marquee tags to add scrolling. If you want it to stop scrolling when you mouse over and stuff, then you'll have to find a javascript marquee script to do that kind of stuff. If you google the marquee HTML tag, you'll see how it is used. Then you just add those tags to this code before and after the table tags.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on October 30, 2008, 02:25:22 PM
I think i have make a wrong request about scroll.

What i mean is like this :
<div style="width: 100%; ' , $online['num_users']>5 ? 'height: 25ex;overflow: auto;' : ''

thats for users online.

How can i put it in this Recent code.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on October 31, 2008, 01:48:22 PM
This is what i take from user online stats :
<div style="width: 100%; ' , $online['num_users']>5 ? 'height: 25ex;overflow: auto;' : ''

how can i make my recent post having overflow limitation. I want my recent post showing 20 latest post but their size only for 5 post. User must scroll down to look more 15 post.
This is my original code : hope soebody can edit it.

global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">
                               <tr><td colspan="6" class="titlebg" align="center">Kiriman Terbaru Di Forum    </td></tr> ';
       $what=ssi_recentTopics('12', NULL, 'array');


        foreach ($what as $topic)
        {
               echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                <span title="',shorten_subject($topic['preview'], $modSettings['hoverLength']),'">', $topic['link'],'</span>';

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="14%">
                                                ', $topic['poster']['link'], '
                                        </td>

                                        </td>
                                        <td class="windowbg" valign="middle" width="15%">
                                                ', $topic['board']['link'], '
                                        </td>


                                        <td class="windowbg2" valign="middle" width="27%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on November 11, 2008, 05:42:45 PM
how can i add also with above code number of views and repy?
Title: Re: "recent topics" in SMF style
Post by: Lafemme on November 11, 2008, 09:13:57 PM
for scrolling : you can make the block scroll by altering the CSS id.  Each block has a unique CSS id.

To find how to target each block, just hover the block edit link, note the blockedit=xx there and use this xx inside tpstyle.css like:     

#blockxx
{
overflow: auto;
}

(sorry bloc, i used some of the text you have replyd to me :)  )

or overflow: scroll;  (for scrolling horizontally and vertically)

I should add this in the /* classes for special block types */   part of the stylesheet. In this way you can easily find it back :)

- edit
:  i also think you should add the height: xxpx;  code... since a blok will expand to the text within it.. and doesn't know when it suppose to scroll or not...
Title: Re: "recent topics" in SMF style
Post by: javier on December 20, 2008, 02:44:43 PM
Hi, excelent work

Quoteadd board ID number like to the function if youw ant to narrow down the boards recent topics are taken from. change it to ssi_recentTopics('8', array('3','56') , 'array') where the numbers 3 and 56 are examples of board ID's.

In these way i selected the boards i do not want to be displayed, i understand,

I need to make exactly the opposite thing, i mean, i have around 200 board,  i want to make a recent topic block to show only 1 or 2 board contents,
I readed almost all the pages of the topic and not found the code.

Ovbiusly i want to avoid to make ssi_recentTopics('8', array('1','2','3','4','5','6','7'............'200') , 'array')


Exist any way?
thanks in advance.
best regards
Title: Re: "recent topics" in SMF style
Post by: IchBin on December 20, 2008, 06:21:47 PM
There are few code snippets that do that here javier. Take a look at the other recent topic code snippets.
Title: Re: "recent topics" in SMF style
Post by: javier on December 30, 2008, 10:40:54 AM
Thanks man,

other question, its possible show the latest created topics instead the latest replied topics?
i have a board with little traffic and after 2 days the latest replys block become empty because no exist new replys.
I want to show the latest created topics or maybe exist any way to avoid the block become empty??

thanks in advance.
Happy Holidays.

Javier

Title: Re: "recent topics" in SMF style
Post by: IchBin on December 30, 2008, 01:28:00 PM
I'm sure its possible, but not with the current code from this topic.
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on December 30, 2008, 06:41:03 PM
Quote from: javier on December 30, 2008, 10:40:54 AM
Thanks man,

other question, its possible show the latest created topics instead the latest replied topics?
i have a board with little traffic and after 2 days the latest replys block become empty because no exist new replys.
I want to show the latest created topics or maybe exist any way to avoid the block become empty??

The number of latest created topics should remain in the block unless you are using the option shown below ...

// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.


If you have set a number of hours to display the topics but you don't have enough traffic to keep something in the block after 2 days, then you shouldn't use the option above.  Take a look at my site ---> http://forum.talesofthehavenexpanse.com/

Scroll down below the countdown to New Years banner.  What is below that is an Article set to show on the Front Page using one of the code snippets in this topic.  As you can see, it shows the last posted to topics, but they remain on there even if the last time the topic was posted to was a month ago, or more.

Is this sort of what you're looking for?

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: javier on December 30, 2008, 08:39:20 PM
Thanks for reply guys,
Currently i using the code from the first post of this topic.

zarprime, yes, exactly like that, you still have topics from November 20 in your "Most Recently Posted To Topics" block.
I tried and tried but have not success making that :( 

what's the code you used for that?

excuse my english, grettings.



Title: Re: "recent topics" in SMF style
Post by: ZarPrime on December 30, 2008, 09:00:58 PM
Javier,

Well, there are so many different versions of this code in this thread I'm almost afraid to post mine here without asking one of the support Mods whether I should do that.  It might confuse people.

I'll tell you what, I'll PM you the code I use and if Les or G6 or Ichbin wants me to post it here I can.  I don't use this in a block though it could be used that way.  Instead, I use it in a php article which is the featured article on my front page.  I'll PM it to you and if the moderators want me to post it here I can do that as well.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: Lesmond on December 30, 2008, 10:31:58 PM
Its OK with me, but wait until you get the flood of people asking you "how can I change this and that"  :tickedoff:
Title: Re: "recent topics" in SMF style
Post by: G6Cad on December 31, 2008, 08:18:10 AM
Zar, feel free to start a new topic and post your code if you want to share it :)
But as Les say, there will be members asking you to twist, turn, redo, rebuild etc etc the code at all times  ;D
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on December 31, 2008, 08:47:14 AM
Quote from: G6 on December 31, 2008, 08:18:10 AM
Zar, feel free to start a new topic and post your code if you want to share it :)
But as Les say, there will be members asking you to twist, turn, redo, rebuild etc etc the code at all times  ;D

Ha Ha :laugh: :laugh: :laugh:

Yeah, I know, that's why I hesitated to post it in the first place. ;)

I certainly don't mind helping people out when it doesn't cut into my own time, well at least not too much.  After all, it's the same code that's in this thread.  I don't know, I may just go ahead and do it, but I'll think about it until tomorrow.  :2funny:

ZP
Title: Re: "recent topics" in SMF style
Post by: zapiy on January 14, 2009, 08:52:31 AM
I am using this code and sometimes only 6 posts are showing.

Any ideas?

Cheers


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block)
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert these lines and those below next section
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '‚ ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '‚ ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ‚';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

        $dummy = array();
        $dummy[] = $row['ID_FIRST_MEMBER'];
        $dummy[] = $row['ID_LAST_MEMBER'];
        loadMemberData($dummy);
        $profile_first = &$user_profile[$row['ID_FIRST_MEMBER']];
        $profile_last = &$user_profile[$row['ID_LAST_MEMBER']];

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $profile_first['member_group_color'] . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $profile_last['member_group_color'] . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:-4px;"' : 'style="margin:-4px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on January 14, 2009, 09:15:13 PM
What version of TP are you using?

If you are using TP 0.98, there is a small problem with this code reading the 20 recent posts.  I can't remember off the top of my head of what I had to do to make this work, but I am going to give you a couple of places to check.

Check these places in order one at a time.  If one of them says "6" change it to "20" and save it.  Then go back to where you are showing this block or article and see if it fixes it.  If not, then go back and change it back to "6" and check the next spot.  Changing one of these should fix it.

1.  Admin / Posts and Topics/ Post Settings / Posts to show on topic summary

2.  Admin / Posts and Topics/ Topic Settings / Number of topics per page in the message index:

3.  Admin / TinyPortal / Front page settings / Number of forum-posts to display on front page:

If this doesn't work, then give us the info we ask for in the Posting Guidelines.html (http://www.tinyportal.net/index.php/topic,581) and we'll go from there.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on January 30, 2009, 06:08:36 PM
with this code i want only show

Subject - Last Poster Name - Category - Time

What must i delete? And also how we add msg preview on mouse over?

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block)
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert these lines and those below next section
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$announce_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName, ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'ââ,¬Å¡ ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'ââ,¬Å¡ ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' ââ,¬Å¡';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

        $dummy = array();
        $dummy[] = $row['ID_FIRST_MEMBER'];
        $dummy[] = $row['ID_LAST_MEMBER'];
        loadMemberData($dummy);
        $profile_first = &$user_profile[$row['ID_FIRST_MEMBER']];
        $profile_last = &$user_profile[$row['ID_LAST_MEMBER']];

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $profile_first['member_group_color'] . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $profile_last['member_group_color'] . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:-4px;"' : 'style="margin:-4px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on January 30, 2009, 11:53:26 PM
Quote from: Mrcare on January 30, 2009, 06:08:36 PM
with this code i want only show

Subject - Last Poster Name - Category - Time

What must i delete? And also how we add msg preview on mouse over?

Why not just use a Recent Topics block?  This block code does a lot more than what you are asking for.

On the "message preview on mouse hover" question, you have asked this several times in different topics over the couple of months.  Everybody has told you that there is a modification at SMF to do this.  Have you looked at it?  Hold on, let me find it for you again ...

... OK, here it is ---> http://custom.simplemachines.org/mods/index.php?mod=263

At this time, I don't know of a block code snippet that will do this.  If you feel like you'd like to do one, I'm sure that it will be of interest to other TP users.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on January 31, 2009, 02:51:03 AM
TQ for suggestion and reply.

Actually i have this,

   <span title="',shorten_subject($topic['preview'], $modSettings

['hoverLength']),'">', $topic['link'],'</span>';


can i add this in this topic code and where to put it?
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on January 31, 2009, 04:18:40 AM
I'm not a coder.  For this reason, I can't answer your last question.  I will send this to one of our coders and ask them to peek in here and have a look but it probably won't be until tomorrow before they will be able to take a look at this.

In the meantime, if you would be so kind, please read the Posting Guidelines (http://www.tinyportal.net/index.php/topic,581) and give us the information that the topic asks for at the bottom, including the url to your site, so that when our coder looks at this they won't have to ask these questions.

Thanks,
ZarPrime
Title: Re: "recent topics" in SMF style
Post by: IchBin on January 31, 2009, 05:26:57 PM
Quote from: Mrcare on January 31, 2009, 02:51:03 AM
TQ for suggestion and reply.

Actually i have this,

   <span title="',shorten_subject($topic['preview'], $modSettings

['hoverLength']),'">', $topic['link'],'</span>';


can i add this in this topic code and where to put it?
What does $topic['preview'] do and where did you get those values? Is there any reason you can't do what Zar suggested a couple of posts above?
Title: Re: "recent topics" in SMF style
Post by: FUBAR on February 01, 2009, 09:01:18 AM
I'm using this code and it's working great except before the number of pages that are listed I get this symbol Â.

Any idea what would be causing this?

I've attached an example below..
Title: Re: "recent topics" in SMF style
Post by: G6Cad on February 01, 2009, 01:34:40 PM
Do you run your forum on uft8 language coding ?
Title: Re: "recent topics" in SMF style
Post by: FUBAR on February 02, 2009, 05:24:19 PM
No, I'm not using uft8 on my forum.
Title: Re: "recent topics" in SMF style
Post by: IchBin on February 02, 2009, 07:15:39 PM
Does it do the same thing in the default theme?
Title: Re: "recent topics" in SMF style
Post by: FUBAR on February 02, 2009, 07:34:24 PM
Yeah, it does it with all themes.
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on February 06, 2009, 11:03:34 PM
Fubar,

Please Read the Reply to the Posting Guidelines (http://www.tinyportal.net/index.php/topic,581) and supply the information requested, including your site url, so that we can help you.

Also, please go to Admin --> Server Settings and tell us what is says for "Default Forum Language".

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: javier on February 09, 2009, 11:35:20 PM
Bloc, its possible use your code but keeping the recent topics visible more time?

I mean, in boards with little traffic after 1 or 2 days the latest replys block become empty because no exist new replys.

Exist any solution for avoid that?

Thanks in advance
best regards.
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on February 10, 2009, 03:59:41 AM
javier,

If you are using the code in the first post in this topic, that code won't allow you to do that but there is code in this topic that will allow this.  Have you read the whole topic?

Perhaps a post I made a while back will help you with this ---> http://www.tinyportal.net/index.php/topic,596.msg219427.html#msg219427

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: Nr|Five on February 10, 2009, 02:57:54 PM
<-- n00b when it comes to modifying code etc.

The first code (first post) is just what I have been looking for. Only 1 thing I'd love to see added (if someone can help me out).

Is the board it was posted on. So basicly like the "recent topics block" but than it will be bigger.

Many thanks in advance

// Nr|Five
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on February 10, 2009, 03:35:59 PM
Nr|Five,

Welcome to TinyPortal.

The first post in this topic does not report the board it was posted in but there are several blocks of code throughout this topic that do.

I know it's a long thread but I would suggest starting at the end and working your way back and find one of the blocks of code that will do what you want by trying each one.  I use one of JA Cortina's blocks of code on one of my sites (the one below my Avatar) as a featured front page article and it does what you want.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: Final60 on February 24, 2009, 02:27:33 PM
Hey guys
Im using the following code on the first page posted by Bloc.



global $scripturl;

echo '
                       <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                                ';
       $what=ssi_recentTopics('5', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

               // Is this topic new? (assuming they are logged in!)
                if ($topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


There are a couple of issues I have with it. Firstly it doesn't display the new image next to the title of the thread when a new reply has been made.

Also it would be great to have "views" and "Replies" inbetween the title and Author.

Lastly I have the following top posters code which I'd love to have on the end of this recent topics block, on the far right. Ive tried the two bits of code in the same php block and they appear to work together, I just can;t seem to position them correctly next to one another.



$result = ssi_topPoster(5, '');
echo '
<font size="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr><td align="left">Username</td><td align="right">Posts</td></tr>
  <tr><td colspan="2"><hr /></td></tr>';
foreach($result as $data)
  echo  '
  <tr><td align="left">', $data['link'] ,'</td><td align="right">',  $data['posts'] ,'</td></tr>';
echo '

</font>
</table>';



Thanks for any interest in my request.
Title: Re: "recent topics" in SMF style
Post by: Paragaya on March 02, 2009, 04:10:30 PM
Good work :)
Title: Re: "recent topics" in SMF style
Post by: Zetan on March 13, 2009, 04:44:00 AM
I've read through this a while back and I'm using one of the codes from somewhere in this thread. I'm happy with the layout of it, it's tidy. There are a few issues with it that I've been meaning to ask for help with.


  • Topic title. This should take you to the "First" post in the topic, not the "Newest / latest / most recent" (whichever way you look at it).
  • (https://www.tinyportal.net/Themes/bz22/images/english/new.gif) icon. This should take you to the "Newest" post in the topic.
  • I have aligned the New icon right. I have tried to make it Absmiddle as well, so that it is in line with the Topic Title, with no success, it aligns right, but under the title. Perhaps there is a better location for it.
  • Last Post icon works correctly.
  • After viewing content selected from the "recent topics", Mine is on the Home Page.. it should cancel the New Topic / Post icons listed in the board index, it doesn't. I think this may be the way the SSI is working.
Here is the code


global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';


I'm no code expert and I have spent time with it, sometimes it's just easier to ask  :buck2:


Thanks
Title: Re: "recent topics" in SMF style
Post by: Ken. on March 13, 2009, 12:52:35 PM
Very good points Zetan, those changes would be nice to have. :up:

I'm using the version that lets you pick the board(s) you want displayed, so hopefully if someone is able to fix the code it will work for that version as well. :)
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on March 29, 2009, 12:34:38 AM
Quote from: Zetan on March 13, 2009, 04:44:00 AM
I've read through this a while back and I'm using one of the codes from somewhere in this thread. I'm happy with the layout of it, it's tidy. There are a few issues with it that I've been meaning to ask for help with.


  • Topic title. This should take you to the "First" post in the topic, not the "Newest / latest / most recent" (whichever way you look at it).
  • (https://www.tinyportal.net/Themes/bz22/images/english/new.gif) icon. This should take you to the "Newest" post in the topic.
  • I have aligned the New icon right. I have tried to make it Absmiddle as well, so that it is in line with the Topic Title, with no success, it aligns right, but under the title. Perhaps there is a better location for it.
  • Last Post icon works correctly.
  • After viewing content selected from the "recent topics", Mine is on the Home Page.. it should cancel the New Topic / Post icons listed in the board index, it doesn't. I think this may be the way the SSI is working.
Here is the code


global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';


I'm no code expert and I have spent time with it, sometimes it's just easier to ask  :buck2:


Thanks

with this code.. how can i add msg preview on mouse over...
Title: Re: "recent topics" in SMF style
Post by: JPDeni on March 29, 2009, 12:58:13 AM
I hadn't seen Zetan's post. Let's see if I can work through his questions.

1. In order to get the topic title to take you to the first post, the link will have to be built instead of just using what SSI.php gives.

Change

echo '<tr><td class="windowbg" valign="middle">', $topic['link'];


to


echo '<tr><td class="windowbg" valign="middle"><a href="' . $scripturl . '?topic=' . $topic['topic']' . $topic['subject'] . '</a>';


2. I'm not sure what the "new" icon does at the moment. If it doesn't act the way you want, you might try changing

      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


to


      echo '<a href="', $topic['href'] . '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


3. I don't know how to align the graphic differently.

4. Good. :)

5. I don't know how to change that problem.

--------------------------------------------------------------

Mrcare, adding a message preview on mouseover would require javascript, which I'm not familiar with. (I didn't want you to think I was just ignoring you.)
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on March 29, 2009, 07:28:33 AM
Quote from: JPDeni on March 29, 2009, 12:58:13 AM
Mrcare, adding a message preview on mouseover would require javascript, which I'm not familiar with. (I didn't want you to think I was just ignoring you.)

Yes... hope one day anybody can make it....

maybe like this

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi477.photobucket.com%2Falbums%2Frr138%2Fsratuspratus%2F1.jpg%3Ft%3D1230145170&hash=cb56315c6c0b4be5900fbc4d95e578777ae01b51)
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on March 30, 2009, 10:37:01 PM
How can i make alternate background for the first and the other topic?
global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 30, 2009, 10:42:56 PM
Do you mean to alternate background colors every other topic row?
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on March 30, 2009, 10:49:36 PM
yes... that is what i mean...
Title: Re: "recent topics" in SMF style
Post by: JPDeni on March 31, 2009, 12:52:28 AM
Change


foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];


to


$bg=0;
foreach ($what as $topic)
  {
    echo '<tr>';
    if ($bg == 0) {
      echo '<td class="windowbg" valign="middle">';
      $bg = 1;
    }
    else {
      echo '<td class="windowbg2" valign="middle">';
      $bg = 0;
    }
    echo $topic['link'];
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on March 31, 2009, 06:48:04 AM
tq...nice code. solved.
Title: Re: "recent topics" in SMF style
Post by: JPDeni on March 31, 2009, 01:35:12 PM
Actually, I did it wrong. Let's try it again:


global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & Time</td></tr>';


$bg=false;
foreach ($what as $topic)
{
echo '<tr class="windowbg' , $bg ? '2' : '' , '">';
$bg = !$bg;
    echo '<td valign="middle">', $topic['link'];

    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';
echo '</td>
<td valign="middle" >', $topic['board']['link'], '</td>';
echo '</td>
<td valign="middle" >', $topic['poster']['link'], '</td>
<td valign="middle" >';
    if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
    echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';


I hadn't realized that each table cell had the background set. It's just as easy to set it at the row level. Also, this code is a whole lot more elegant than the previous one.
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on March 31, 2009, 02:04:33 PM
yes... tq... very nice upgrade...
Title: Re: "recent topics" in SMF style
Post by: Dark_Star on April 09, 2009, 12:34:29 AM
How do you get it to pick up the member Group colors?
Title: Re: "recent topics" in SMF style
Post by: JPDeni on April 09, 2009, 12:48:17 AM
It would require rewriting the code, because ssi_recentTopics doesn't include group colors.
Title: Re: "recent topics" in SMF style
Post by: Zetan on April 09, 2009, 10:39:27 AM
Quote from: JPDeni on March 29, 2009, 12:58:13 AM
I hadn't seen Zetan's post. Let's see if I can work through his questions.

1. In order to get the topic title to take you to the first post, the link will have to be built instead of just using what SSI.php gives.

Change

echo '<tr><td class="windowbg" valign="middle">', $topic['link'];


to


echo '<tr><td class="windowbg" valign="middle"><a href="' . $scripturl . '?topic=' . $topic['topic']' . $topic['subject'] . '</a>';


2. I'm not sure what the "new" icon does at the moment. If it doesn't act the way you want, you might try changing

      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


to


      echo '<a href="', $topic['href'] . '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


3. I don't know how to align the graphic differently.

4. Good. :)

5. I don't know how to change that problem.

--------------------------------------------------------------

Mrcare, adding a message preview on mouseover would require javascript, which I'm not familiar with. (I didn't want you to think I was just ignoring you.)

Thanks for the reply Deni, seems I missed your reply too. As you know, I'm having internet problems at home and am finding it difficult keeping up with things.

I'll have a proper look over this when I can.
Title: Re: "recent topics" in SMF style
Post by: FUBAR on May 24, 2009, 11:09:39 PM
I'm currently using the code posted by J.A.Cortina here. (http://www.tinyportal.net/index.php/topic,596.msg173244.html#msg173244)

The "Last Post" column is a little squished and is making 3 lines of text. 

I would like to like to move the last 3 columns to the left and make the "Subject" column smaller.  I've taken a look at the "JAC_Functions.php" file and tried to modify the Full Block width settings but just can't seem to get it right. 

This is the area I'm trying to modify...
    if ($parm['style'] == 'fullblock') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';


If anyone can help it would be greatly appreciated.  :)


Title: Re: "recent topics" in SMF style
Post by: JPDeni on May 24, 2009, 11:28:54 PM
If you're going to use percentages for the widths of your table cells, you should be sure that they total 100%. I'm not sure why the first cell spans two columns, but you would probably do better to define your cell widths on a row where there are no colspans.
Title: Re: "recent topics" in SMF style
Post by: zapiy on June 21, 2009, 10:14:55 PM
Added this to a php block minus the php code at the top and bottom. Nothing shows on the frontpage.


Quote from: J.A.Cortina on January 09, 2008, 07:21:21 PM
And, finally, the function itself:
<?php

function JAC_RecentTopics($parm = array(), $output 'echo')
{
    global 
$context$settings$scripturl$txt$db_prefix$ID_MEMBER$user_info$modSettings$user_profile$options;
    
$do_query 1;

    
$valid_recent_types = array('last''unreplied''hours''notify''bookmark''started');
    
$valid_array_types = array('X''I''T');
    
$valid_out_styles = array('fullblock''full''condensed''line'); 
    
$valid_sorts = array('last_post''subject''starter''replies''views''first_post');
    
$sort_dirs = array(
        
'last_post' => array('DESC''asc'),
        
'subject' => array('ASC''desc'),
        
'starter' => array('ASC''desc'),
        
'replies' => array('ASC''desc'),
        
'views' => array('ASC''desc'),
        
'first_post' => array('ASC''desc'),
    );

    
$output strtolower($output) != 'array' 'echo' 'array';

    if (!
is_array($parm)) {
        if (
$output 'array') {
            return array();}
        else {
            echo 
'Unexpected argument - expecting parameter array)';
            return; }
    }

if(!empty($options['num_topics_page']))
$modSettings['defaultMaxTopics'] = $options['num_topics_page'];
if(!empty($options['num_posts_page']))
$modSettings['defaultMaxMessages'] = $options['num_posts_page'];

    
$parm['type'] = (isset($parm['type']) && !empty($parm['type']) && in_array(strtolower($parm['type']), $valid_recent_types)) ? strtolower($parm['type']) : $valid_recent_types[0];

    
$parm['count'] = (isset($parm['count']) && !empty($parm['count']) && is_numeric($parm['count'])) ? $parm['count'] : 0;

    
$parm['array_type'] = (isset($parm['array_type']) && !empty($parm['array_type']) && in_array(strtoupper($parm['array_type']), $valid_array_types)) ? strtoupper($parm['array_type']) : $valid_array_types[0];

    
$parm['select_array'] = (isset($parm['select_array']) && !empty($parm['select_array']) && is_array($parm['select_array'])) ? $parm['select_array'] : array();

    
$parm['style'] = (isset($parm['style']) && !empty($parm['style']) && in_array(strtolower($parm['style']), $valid_out_styles)) ? strtolower($parm['style']) : $valid_out_styles[0];

    
$parm['heading'] = (isset($parm['heading'])) ? $parm['heading'] : '';

    
$parm['sort_by_start'] = (isset($parm['sort_by_start']) && ($parm['sort_by_start'] === true)) ? true false;

    
$parm['user_id'] = (isset($parm['user_id']) && !empty($parm['user_id']) && is_numeric($parm['user_id'])) ? $parm['user_id'] : 0;
    
$parm['user_id'] = $parm['user_id'] != $parm['user_id'] : $ID_MEMBER;

    
$parm['start_num'] = (isset($parm['start_num']) && !empty($parm['start_num']) && is_numeric($parm['start_num'])) ? $parm['start_num'] : 0;

    
$parm['sort_col'] = (isset($parm['sort_col']) && !empty($parm['sort_col']) && in_array(strtolower($parm['sort_col']), $valid_sorts)) ? strtolower($parm['sort_col']) : $valid_sorts[0];

    
$parm['sort_dir'] = (isset($parm['sort_dir']) && ((strtoupper($parm['sort_dir']) == 'ASC') || (strtoupper($parm['sort_dir']) == 'DESC'))) ? strtoupper($parm['sort_dir']) : '';
    
$cur_dir $parm['sort_dir'] != '' $parm['sort_dir'] : $sort_dirs[$parm['sort_col']];

    
$parm['save_url_stub'] = (isset($parm['save_url_stub'])) ? $parm['save_url_stub'] : '';

    
$parm['mem_colors'] = (isset($parm['mem_colors']) && ($parm['mem_colors'] === false)) ? false true;

    
$parm['height'] = (isset($parm['height'])) ? $parm['height'] : 0;

    
$parm['per_page'] = (isset($parm['per_page']) && !empty($parm['per_page']) && is_numeric($parm['per_page'])) ? $parm['per_page'] : 0;
    
$parm['per_page'] = $parm['per_page'] > $parm['per_page'] : $modSettings['defaultMaxTopics'];

    
$constraint '';
    if (
$parm['type'] == 'bookmark')
if( mysql_num_rowsmysql_query("SHOW TABLES LIKE '"$db_prefix"bookmarks'") ) == )
            
$parm['type'] == 'notify';

    if ((
$parm['type'] == 'bookmark') || ($parm['type'] == 'notify')) {
    
$watched_topics = array();
        if (
$parm['type'] == 'bookmark')
        
$request db_query("SELECT ID_TOPIC FROM {$db_prefix}bookmarks WHERE ID_MEMBER = {$parm['user_id']}"__FILE____LINE__);
        if (
$parm['type'] == 'notify')
        
$request db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$parm['user_id']} AND ID_BOARD = 0"__FILE____LINE__);
    
while ($row mysql_fetch_assoc($request))
            
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
if (count($watched_topics) == 0)
$do_query 0;
    
else
    
$constraint =' t.ID_TOPIC IN (' implode(', '$watched_topics) . ')';
    }

    
$type_methods = array(
        
'last' =>   ($parm['array_type'] == 'X' ? (($parm['count'] != 0) ? ('t.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - (150 max($parm['count'], $parm['per_page'])))) : '1' ) : '1'),
        
'unreplied' => 't.numReplies = 0',
        
'hours' => $parm['count'] == 'ml.posterTime >= ' strtotime('1 day ago') : 'ml.posterTime >= ' strtotime($parm['count'] . ' hours ago'),
        
'notify' => $constraint,
        
'bookmark' => $constraint,
        
'started' => 't.ID_MEMBER_STARTED = ' $parm['user_id'],
    );
    
$type_method_clause $type_methods[$parm['type']];

    
$select_methods = array(
        
'X' => count($parm['select_array']) == '' ' AND b.ID_BOARD NOT IN (' implode(', '$parm['select_array']) . ')',
        
'I' => count($parm['select_array']) == '' ' AND b.ID_BOARD IN (' implode(', '$parm['select_array']) . ')',
        
'T' => count($parm['select_array']) == '' ' AND t.ID_TOPIC IN (' implode(', '$parm['select_array']) . ')',
    );
    
$select_method_clause $select_methods[$parm['array_type']];

    
$sort_methods = array(
    
'last_post' => ($parm['sort_by_start'] ? 't.ID_FIRST_MSG' 't.ID_LAST_MSG'),
    
'subject' => 'ms.subject',
    
'starter' => 'IFNULL(mems.realName, ms.posterName)',
    
'replies' => 't.numReplies',
    
'views' => 't.numViews',
    
'first_post' => 't.ID_TOPIC',
    );
    
$sort_method_clause ' ORDER BY '$sort_methods[$parm['sort_col']] . ' ' . ($parm['sort_dir'] == '' $sort_dirs[$parm['sort_col']][0] : $parm['sort_dir']);

    
$type_heading = array(
   
    'last' => 'Most Recently Posted To Topics',
       
'unreplied' => 'Unreplied To Topics',
        
'hours' => 'Topics Posted To In Last '. ($parm['count'] == 24 $parm['count']) . ' Hours',
        
'notify' => 'Topics Being Watched' . ($ID_MEMBER == $parm['user_id'] ? '' : (' by User# ' $parm['user_id'])),
        
'bookmark' => 'Topics Bookmarked' . ($ID_MEMBER == $parm['user_id'] ? '' : (' by User# ' $parm['user_id'])),
        
'started' => 'Topics Started ' . ($ID_MEMBER == $parm['user_id'] ? ' by You' : (' by User# ' $parm['user_id'])),
    );

$limit_clause $parm['type'] == 'hours' '' : ($parm['count'] == ' LIMIT '.$modSettings['defaultMaxTopics'] : ' LIMIT '.$parm['count']);

$stable_icons = array('xx''thumbup''thumbdown''exclamation''question''lamp''smiley''angry''cheesy''grin''sad''wink''moved''recycled''wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$groupcolors = array();
        if (
$parm['mem_colors']) {
    
$request db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups"__FILE____LINE__);
     while ($row mysql_fetch_assoc($request))
     $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
    
mysql_free_result($request);
    
}

        if (
$parm['style'] == 'full') {
$request db_query("
SELECT b.ID_BOARD
FROM 
{$db_prefix}boards AS b
WHERE " 
$user_info['query_see_board'] . (!empty($modSettings['recycle_enable']) && ($modSettings['recycle_board'] > 0) ? "
AND b.ID_BOARD != " 
. (int) $modSettings['recycle_board'] : '') .
$select_method_clause,
__FILE____LINE__);
    
$boards = array();
    
while ($row mysql_fetch_assoc($request))
    
$boards[] = $row['ID_BOARD'];
    
mysql_free_result($request);
    
$query_this_board = empty($boards) ? '' 'WHERE t.ID_BOARD IN (' implode(', '$boards) . ')';

    $request db_query("
    SELECT COUNT(*), MIN(t.ID_LAST_MSG)
       FROM 
{$db_prefix}topics AS t, {$db_prefix}messages AS ml " .
$query_this_board "
AND ml.ID_MSG = t.ID_LAST_MSG " 
.
$select_method_clause "
AND " 
$type_method_clause,
__FILE____LINE__);
    
list ($num_topics$min_message) = mysql_fetch_row($request);
    
mysql_free_result($request);
            
$limit_clause 'LIMIT ' $parm['start_num'] . ', ' $parm['per_page'];
        }

$query "
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group, mems.ID_POST_GROUP as mems_pgroup,
ml.subject AS lastSubject, b.memberGroups, meml.ID_POST_GROUP as meml_pgroup,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
ml.body AS lastBody, ms.body AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from'
) . "
FROM (
{$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN 
{$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN 
{$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " 
$type_method_clause " " .
    $select_method_clause " " .
   "AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD " 
.
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > " AND b.ID_BOARD != $modSettings[recycle_board]'') .
   " AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " 
$user_info['query_see_board'] . " " .
$sort_method_clause " " $limit_clause;

$request db_query($query__FILE____LINE__);

$topic_ids = array();
while ($row mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '')));

if ($row['ID_FIRST_MSG'] == $row['ID_LAST_MSG'])
{
$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];
}
        else
        {
    $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '')));
        }

// Decide how many pages the topic should have.
$topic_length $row['numReplies'] + 1;
if ($topic_length $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa 1;
for ($tmpb 0$tmpb $topic_length$tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.' $tmpb ';topicseen">' $tmpa '</a>';
$tmpa++;
}

// Show links to all the pages?
if (count($tmppages) <= 5)
$pages 'Ã,« ' implode(' '$tmppages);
// Or skip a few?
else
$pages 'Ã,« ' $tmppages[0] . ' ' $tmppages[1] . ' ... ' $tmppages[count($tmppages) - 2] . ' ' $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length $modSettings['enableAllMessages'])
$pages .= '  <a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0;all">' $txt[190] . '</a>';
$pages .= ' Ã,»';
}
else
$pages '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['firstIcon'] . '.gif') ? 'images_url' 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['lastIcon'] . '.gif') ? 'images_url' 'default_images_url';
}

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl '?action=profile;u=' $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? ('<a href="' $scripturl '?action=profile;u=' $row['ID_FIRST_MEMBER'] . '" title="' $txt[92] . ' ' $row['firstPosterName'] . '">' . ( $parm['mem_colors'] ? ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']])  ? '<font color="'. ( !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : $groupcolors[$row['mems_pgroup']] ) . '">' '' ) : '' )  . $row['firstPosterName'] . (( $parm['mem_colors'] && ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']]))) ? '</font>' '' ) . '</a>' ) : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true$row['firstPosterTime']),
'subject' => $row['firstSubject'],
'short_subject' => shorten_subject($row['firstSubject'], 25),
'preview' => shorten_subject($row['firstBody'],128),
'body' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' $row['firstIcon'] . '.gif',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0;topicseen">' $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl '?action=profile;u=' $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' $scripturl '?action=profile;u=' $row['ID_LAST_MEMBER'] . '" title="' $txt[92] . ' ' $row['lastPosterName'] . '">' . ( $parm['mem_colors'] ? ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]) ? '<font color="'. ( !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : $groupcolors[$row['meml_pgroup']] ) .'">' '' ) : '' ) . $row['lastPosterName'] . (( $parm['mem_colors'] && ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]))) ? '</font>' '' ) . '</a>' $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true$row['lastPosterTime']),
'subject' => $row['lastSubject'],
'short_subject' => shorten_subject($row['lastSubject'], 25),
'preview' => shorten_subject($row['lastBody'],128),
'body' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' $row['lastIcon'] . '.gif',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . ';topicseen#msg' $row['ID_LAST_MSG'],
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . ';topicseen#msg' $row['ID_LAST_MSG'] . '">' $row['lastSubject'] . '</a>'
),
'new' => !$row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl '?topic=' $row['ID_TOPIC'] . '.msg' $row['new_from'] . ';topicseen#new',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['new_from']) . ';topicseen' . ($row['numReplies'] == '' 'new'),
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['new_from']) . ';topicseen#msg' $row['new_from'] . '">' $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result db_query("
SELECT ID_TOPIC
FROM 
{$db_prefix}messages
WHERE ID_TOPIC IN (" 
implode(', '$topic_ids) . ")
AND ID_MEMBER = 
$ID_MEMBER"__FILE____LINE__);
while ($row mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if ($output == 'array')
    return $topics;

if ( ($parm['style'] == 'full') || ($parm['style'] == 'fullblock') )
{
if (!empty($topics))
    {

    if ($parm['style'] == 'full') {
        $page_url $parm['save_url_stub'] . ';sort=' $parm['sort_col'] . ( ($parm['sort_dir'] != '') ? ';'.$parm['sort_dir'] : '');
        $current_page = (int) $parm['start_num'] / $parm['per_page'];
        $links = array(
            'first' => $parm['start_num'] >= $parm['per_page'] ? $scripturl $page_url ';start=0' '',
            'prev' => $parm['start_num'] >= $parm['per_page'] ? $scripturl .  $page_url ';start=' . ($parm['start_num'] - $parm['per_page']) : '',
            'next' => $parm['start_num'] + $parm['per_page'] < $num_topics $scripturl .  $page_url ';start=' . ($parm['start_num'] + $parm['per_page']) : '',
            'last' =>  ( ($parm['start_num'] + $parm['per_page']) < $num_topics) ? ($scripturl .  $page_url ';start=' . (floor(($num_topics 1) / $parm['per_page']) * $parm['per_page']) ) : '',
            'up' => $scripturl,
        );
        
$page_info = array(
            'current_page' => floor($parm['start_num'] / $parm['per_page']) + 1,
        
    'num_pages' => floor(($num_topics 1) / $parm['per_page']) + 1,
                    
'page_index' => constructPageIndex($scripturl $parm['save_url_stub'] . ';sort=' $parm['sort_col'] . ( ($parm['sort_dir'] != '') ? ';'.$parm['sort_dir'] : ''), $parm['start_num'], $num_topics$parm['per_page'], false),
        );

            
echo '
                 <table border="0" width="100%" cellpadding="0" cellspacing="0">
                  <tr>
                  <td class="middletext" valign="middle">' 
$txt[139] . ': ' $page_info['page_index'] . '</td>
                 </tr>
                 </table>'
;
    }

    echo '
        <div class="tborder" '
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' 'style="margin:0px;"''>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">'
;


if ($parm['heading'] != 'SUPPRESS') {
    
echo '
<tr>'
;
echo '
<td class="titlebg" colspan="7">'
, ($parm['heading'] == '' $type_heading[$parm['type']] : $parm['heading']), '</td>';
echo '
</tr>'
;
}

    if ($parm['style'] == 'fullblock') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>'
$txt[70], '
</td><td width="14%">'
$txt[109], '
</td><td width="4%" align="center">'
$txt[110], '
</td><td width="4%" align="center">'
$txt[301], '
</td><td width="24%">'
$txt[111], '
</td>
</tr>'
;
    }

    if ($parm['style'] == 'full') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>
<a href="'
$parm['save_url_stub'], ';sort=subject', ($parm['sort_col'] != 'subject' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'subject') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="14%">
    <a href="'
$parm['save_url_stub'], ';sort=starter', ($parm['sort_col'] != 'starter' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'starter') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="4%" align="center">
    <a href="'
$parm['save_url_stub'], ';sort=replies', ($parm['sort_col'] != 'replies' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'replies') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="4%" align="center">
    <a href="'
$parm['save_url_stub'], ';sort=views', ($parm['sort_col'] != 'views' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'views') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="24%">
    <a href="'
$parm['save_url_stub'], ';sort=last_post', ($parm['sort_col'] != 'last_post' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'last_post') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td>
</tr>'
;
    }

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' 
$settings['images_url'] . '/topic/' $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' 
$topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' 
$topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' '' '" width="48%" valign="middle">' $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' 
$settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' '' $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' 
$settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' '';
if ($topic['new'])
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="'$topic['new_href'], '"> <img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="'$txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
  echo '
<span class="smalltext">'
$topic['pages'], '<br>'$txt['smf88'], ' '$topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
'
$topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
'
$topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
'
$topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="'
$topic['last_post']['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="'$txt[111], '" title="'$txt[111], '" style="float: right;" /></a>
<span class="smalltext">
'
$topic['last_post']['time'], '<br />
'
$txt[525], ' '$topic['last_post']['member']['link'], '
</span>
</td>
</tr>'
;
}

    echo '</table>';

    echo '</div>';

    if ($parm['style'] == 'full') {

            
echo '
                 <table border="0" width="100%" cellpadding="0" cellspacing="0">
                  <tr>
                  <td class="middletext" valign="middle">' 
$txt[139] . ': ' $page_info['page_index'] . '</td>
                 </tr>
                 </table>'
;

    echo'
<div class="tborder"><div class="titlebg2">
<table cellpadding="8" cellspacing="0" width="55%">
<tr>
<td align="left" style="padding-top: 2ex;" class="smalltext">'
, !empty($modSettings['enableParticipation']) ? '
<img src="' 
$settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' $txt['participation_caption'] . '<br />' '''
<img src="' 
$settings['images_url'] . '/topic/normal_post.gif" alt="" align="middle" /> ' $txt[457] . '<br />
<img src="' 
$settings['images_url'] . '/topic/hot_post.gif" alt="" align="middle" /> ' $txt[454] . '<br />
<img src="' 
$settings['images_url'] . '/topic/veryhot_post.gif" alt="" align="middle" /> ' $txt[455] . '
</td>
<td align="left" valign="top" style="padding-top: 2ex;" class="smalltext">
<img src="' 
$settings['images_url'] . '/icons/quick_lock.gif" alt="" align="middle" /> ' $txt[456] . '<br />' . ($modSettings['enableStickyTopics'] == '1' '
<img src="' 
$settings['images_url'] . '/icons/' . (!empty($settings['seperate_sticky_lock']) ? 'quick_sticky' 'normal_post_sticky') . '.gif" alt="" align="middle" /> ' $txt['smf96'] . '<br />' '') . ($modSettings['pollMode'] == '1' '
<img src="' 
$settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' $txt['smf43'] : '') . '
</td>
</tr>
</table>
</div>'
;
    }

    }
else
    

    
echo '<b><u>',($parm['heading'] == '' $type_heading[$parm['type']] : $parm['heading']),'<br><br>No Topics Match Search Criteria</u></b>';
    }
}

if ($parm['style'] == 'condensed')
{
$counter=1$cmax=count($topics);
$height_clause = (isset($parm['height']) && ($parm['height'] > 0) ? ' height: '.$parm['height'].'px;' '');
echo ' <div style="width: 100%;'$height_clause' overflow: auto;">
<div class="windowbg" style="width: 100%; overflow: hidden;">'
;
foreach ($topics as $w)
{
echo '
<div class="smalltext"><a href="'
.$w['last_post']['href'].'">'. ($w['new'] ? '<b>' '') . $w['last_post']['short_subject'] . ($w['new'] ? '</b>' '') .'</a></div>
<div class="smalltext">'
$txt[525], ' <b>'$w['last_post']['member']['link'], '</b> ';
if($w['new'])
echo '<a href="'.$w['new_href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '</div><div class="smalltext">';
echo '['.$w['last_post']['time'].']
</div>'
;

if($counter != $cmax)
echo '<hr />';
$counter++;
}
echo '
</div></div>'
;
}

if ($parm['style'] == 'line')
{
$counter=1$cmax=count($topics);
$height_clause = (isset($parm['height']) && ($parm['height'] > 0) ? ' height: '.$parm['height'].'px;' '');
echo ' <div style="width: 100%;'$height_clause' overflow: auto;">
<div class="windowbg" style="width: 100%; overflow: hidden;">'
;
foreach ($topics as $w)
{
echo '<div class="windowbg'. ((($counter 2) == 0) ? '' '2') . '" style="width: 100%;line-height: 1.4em">';
echo '
<span class="smalltext"><a href="'
.$w['last_post']['href'].'">'. ($w['new'] ? '<b>' '') . $w['last_post']['subject'] . ($w['new'] ? '</b>' '') .'</a>  </span>
<span class="smalltext">(in '
.$w['board']['link'].')  </span>
<span class="smalltext">'
$txt[525], ' <b>'$w['last_post']['member']['link'], '</b>  </span>
<span class="smalltext">'
;
if($w['new'])
echo '<a href="'.$w['new_href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '['.$w['last_post']['time'].']
</span><br />'
;

$counter++;
echo '
</div>'
;
}
echo '
</div></div>'
;
}

}

?>

Title: Re: "recent topics" in SMF style
Post by: IchBin on June 22, 2009, 03:11:03 AM
The instructions for using that code is posted in the post directly before the one you copied that code from. Please read it.
http://www.tinyportal.net/index.php/topic,596.msg173244.html#msg173244
Title: Re: "recent topics" in SMF style
Post by: zapiy on June 22, 2009, 09:11:42 PM
Ok i ended up using the JAC_functions.php file and outputting via an article my question is how do you make it so it shows the last 20 posts regardless if you have seen them? We may not have 20 posts everyday but i want the block to remmain the same size whatever..Can that be done?

Cheers
Title: Re: "recent topics" in SMF style
Post by: IchBin on June 22, 2009, 11:48:09 PM
I wouldn't have any idea how his code works. If I were you, I'd look at some of the other topics that do essentially the same thing and see if you get what you want.
Title: Re: "recent topics" in SMF style
Post by: Excalibur J on June 22, 2009, 11:58:49 PM
I don't think functions call themselves and all you added were the functions without calling them.

The post before the one with the separate functions shows how the functions can be actually called from either an article or a block. Put the code you want in front of the function definitions.
Title: Re: "recent topics" in SMF style
Post by: zapiy on June 30, 2009, 10:06:46 PM
How? Please
Title: Re: "recent topics" in SMF style
Post by: Excalibur J on June 30, 2009, 10:46:08 PM
You wrote that you put it in a block.

The second code block in message:
http://www.tinyportal.net/index.php/topic,596.msg173244.html#msg173244
is about using it in a php box.

It all depends on what you want shown and how. You supply the parameters and then call the function. Because you are making the function local, you don't want/need to use the part near the top which is used to include the function when it's in an external file and almost all of the rest of the code shown is comments documenting use.

Example:
global $settings, $user_info, $modSettings, $sourcedir;

$parm = array();

$parm['type'] = 'last';
$parm['count'] = 5;
$parm['style'] = 'fullblock';

JAC_RecentTopics($parm, 'echo');

...

<this is where the code you have in place already is>


Will give 5 most recently posted to topics in center-block SMF-Style.

Example:
global $settings, $user_info, $modSettings, $sourcedir;

$parm = array();

$parm['type'] = 'last';
$parm['count'] = 10;
$parm['style'] = 'condensed';
$parm['height'] = 200;

JAC_RecentTopics($parm, 'echo');

...

<this is where the code you have in place already is>


Will give 10 most recently posted to topics in side block 200 pixels high with a scroll bar.
Title: Re: "recent topics" in SMF style
Post by: katers on July 31, 2009, 04:23:13 AM
Hi can you please tell me if this is the one that is used on this forum?
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on July 31, 2009, 01:53:02 PM
Hi twister,

If you are asking if the code in this topic is the same as the standard TP Recent Topics block, the answer is no.  The code talked about in this topic is designed for a center block, or an upper block in the newer TP versions.  The best way to see how it works is to stick it into one of those panels and check it out.  I am using one of the blocks of code in this topic on one of my sites and the way it's formatted, it wouldn't look right in a left or right panel.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: katers on July 31, 2009, 05:51:34 PM
Ok, thank you.  Yes I am looking for something that fits on a side block like this forum.  I will keep searching.
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on July 31, 2009, 10:49:03 PM
Twister,

I should have asked you this before but is the Recent Topics block in the left panel here on TinyPortal.net the one you are wanting to use?  If so, this is the same standard block type called "Recent Topics" which is available as standard in all versions of of TP 1.x.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: katers on July 31, 2009, 11:59:07 PM
Awesome! Thank you very much!
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on August 01, 2009, 12:04:16 AM
Twister,

Sure.  NP.  I'm glad we got you solved. :up:

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: alhaudhie on August 26, 2009, 05:08:12 PM
Quote from: JPDeni on March 31, 2009, 01:35:12 PM
Actually, I did it wrong. Let's try it again:


global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & Time</td></tr>';


$bg=false;
foreach ($what as $topic)
{
echo '<tr class="windowbg' , $bg ? '2' : '' , '">';
$bg = !$bg;
    echo '<td valign="middle">', $topic['link'];

    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';
echo '</td>
<td valign="middle" >', $topic['board']['link'], '</td>';
echo '</td>
<td valign="middle" >', $topic['poster']['link'], '</td>
<td valign="middle" >';
    if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
    echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';


I hadn't realized that each table cell had the background set. It's just as easy to set it at the row level. Also, this code is a whole lot more elegant than the previous one.
whith this code above.. how can i add number off post read and numbers of reply for every topic post?
Title: Re: "recent topics" in SMF style
Post by: zapiy on September 21, 2009, 08:42:08 PM
Hi guys, I am using the J.A Cortina code..I have used only the Functions code in an Article with the need of the JAC file..Anyway sometimes i have 20 odd posts in the block and other times any amount below that number..Alos i may have 20 showing and i click one to read and post in then i go back to the frontpage and now i only have 4 or 5..Please help this is driving me nuts lol

www.maturevideogamer.co.uk
smf 1.1.10
TP1.0 beta 4

As a guest it works fine but i kinda expect that.

Cheers
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on September 22, 2009, 02:38:54 PM
zapiy,

You probably just have one or more of the parameters in the code set wrong, perhaps only to show new posts or something like that.  If you want to post the code you are using in your next post (in code tags please), I will take a look at it and see if I can figure it out.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on September 22, 2009, 04:40:45 PM
Thanks Zarprime....


global $scripturl, $sourcedir, $user_info;

$func_location = $sourcedir . '/JAC_Functions.php';

if (!function_exists('JAC_RecentTopics'))
if (file_exists($func_location)) require_once($func_location);
if (!function_exists('JAC_RecentTopics')) {
echo 'Could not find the desired recent topics function.';
return;}

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
//
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on your topic notify list (Admin can specify user besides self) -OR-
// most recent XX topics on your topic bookmarks list (Admin can specify user besides self) -OR-
// most recent XX topics started by you (Admin can specify user besides self)
//
// All in the detailed topic format (Like SMF's View Unread Topics - with or without paging)*
// -OR- Minimal side block recent topics
//  -OR-    Brief, single line format
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to $modSettings['defaultMaxTopics']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to $modSettings['defaultMaxTopics']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// index.php?page=##;type=bookmark or index.php?page=##;type=bookmark;count=50
// Topics in the bookmark list up to number
// specified in 'count' or a maximum of 100 topics.    REQUIRES Bookmark Mod
//
// *** Admins Only ***
// index.php?page=##;type=bookmark;user=XXX or index.php?page=##;type=bookmark;user=XXX;count=50
// Topics in the bookmark list of specified user up to number
// specified in 'count' or a maximum of 100 topics.    REQUIRES Bookmark Mod
//
// index.php?page=##;type=started or index.php?page=##;type=started;count=50
// Topics started by current user list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
// Topics started by specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument 'create' to sort by topic creation sequence (most recent first)
// rather than by last reply sequence
//
//  Add style=              fullblock - Full SMF detail format suitable for center blocks
// full      - Full SMF detail format with paging, column sort - ARTICLE ONLY
// condensed - Minimal Info Multiline Recent Topics sutable for side blocks
// line      - Minimal Info Single Line Recent Topics sutable for side/center blocks
//
// Unconditional Restrictions (only most restrictive given will be used):
//  Add excludes=#,#,#,#,#; Boards whose Topics are NOT to be listed. (least restrictive)
//  Add includes=#,#,#,#,#; Only boards whose Topics ARE to be listed.
//  Add topics=#,#,#,#,#; Only Topics which ARE to be listed. (most restrictive)
//



//==========================================================================================================================

$default_type = 'last';
$default_excludes = array();
$default_style = 'fullblock';
$default_colors = 'Y';

$parm = array();

$parm['type'] = strtolower($default_type);
if (isset($_GET['type'])) $parm['type'] = strtolower($_GET['type']);

if (isset($_GET['count'])) $parm['count'] = strtolower($_GET['count']);

$select_array = 'X';
$select_array = array();
if (isset($_GET['topics'])) {
$parm['select_array'] = explode(',',$_GET['topics']);
$parm['array_type'] = 'T'; }
elseif (isset($_GET['includes'])) {
$parm['select_array'] = explode(',',$_GET['includes']);
$parm['array_type'] = 'I'; }
elseif (isset($_GET['excludes'])) {
$parm['select_array'] = explode(',',$_GET['excludes']);
$parm['array_type'] = 'X'; }
else {
$parm['select_array'] = $default_excludes;
$parm['array_type'] = 'X'; }

$parm['style'] = strtolower($default_style);
if (isset($_GET['style'])) $parm['style'] = strtolower($_GET['style']);

if (isset($_GET['create'])) $parm['sort_by_start'] = true;

if (isset($_GET['user'])) $parm['user_id'] = strtolower($_GET['user']);

if (isset($_GET['start'])) $parm['start_num'] = strtolower($_GET['start']);

if (isset($_GET['sort'])) $parm['sort_col'] = strtolower($_GET['sort']);

if (isset($_GET['asc']) || isset($_GET['ASC'])) $parm['sort_dir'] = 'asc';
if (isset($_GET['desc']) || isset($_GET['DESC'])) $parm['sort_dir'] = 'desc';

$parm['mem_colors'] = (strtoupper($default_colors) == 'Y') ? true : false;
if (isset($_GET['colors'])) $parm['mem_colors'] = true;

$parm['save_url_stub'] =  '?page='.$_GET['page'] .
                ( isset($_GET['type']) ? ';type='.$_GET['type'] : '' ) .
                ( isset($_GET['count']) ? ';count='.$_GET['count'] : '' ) .
                ( isset($_GET['excludes']) ? ';excludes='.$_GET['excludes'] : '' ) .
                ( isset($_GET['includes']) ? ';includes='.$_GET['includes'] : '' ) .
                ( isset($_GET['topics']) ? ';topics='.$_GET['topics'] : '' ) .
                ( isset($_GET['create']) ? ';create' : '' ) .
                ( isset($_GET['user']) ? ';user='.$_GET['user'] : '' ) .
                ( isset($_GET['style']) ? ';style='.$_GET['style'] : '' ) .
                ( isset($_GET['colors']) ? ';colors' : '' );

echo '';
$topics = JAC_RecentTopics($parm, 'echo');
echo '';
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on September 22, 2009, 11:18:41 PM
zapiy,

Can you give me the link to the post here where you got this code from and also a link to your site so that I can see what it looks like in action right now.

Thanks,
ZP
Title: Re: "recent topics" in SMF style
Post by: zapiy on September 23, 2009, 06:24:46 PM
http://www.tinyportal.net/index.php/topic,596.msg173244.html#msg173244

www.maturevideogamer.co.uk

Thanks
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on September 23, 2009, 11:48:59 PM
zapiy,

OK, well, that one would take me a while to figure out.  Try the one below instead.  I use it in a php article and set it to be the featured article on the Front Page (no title/no frame).  I know that it will continue to show topics even after you have read the new ones.  If you want to see what it looks like on one of my Forums click the globe below my name on the left ...


global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
$exclude_boards = array(); // KEEP (to preserve variable declaration)
// $exclude_boards = array(5); //  Exclude single board
//  $exclude_boards = array(55,69); //  Exclude multiple boards
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
// This will give most recent XX posted to topics -OR-
// most recent XX unreplied to topics -OR-
// topics posted to in last XX hours -OR-
// most recent XX topics on topic notify list
//
// Sorts by most recent reply (descending; most recent first) -OR-
//          creation order (descending; most recent first)
//
// All in the detailed topic format
//
//
// Default
// index.php?page=##
// most recent posted to topics - will list
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;count=50 or index.php?page=##;type=last;count=50
// 50 most recently posted to topics
//
// index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
// Most recent unreplied to topics - will
// list number specified in 'count' or default to
// number equal to  $settings['number_recent_posts']
//
// index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
// Topics posted to in last number of hours
// specified in 'count' or default to 24.
//
// index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
// Topics in topic notifcation list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
// Topics in topic notifcation list of specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// index.php?page=##;type=started or index.php?page=##;type=started;count=50
// Topics started by current user list up to number
// specified in 'count' or a maximum of 100 topics.
//
// *** Admins Only ***
// index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
// Topics started by specified user up to number
// specified in 'count' or a maximum of 100 topics.
//
// Add argument order=create to sort by topic creation sequence (most recent first)
// rather than by last reply sequence

$do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
// $heading = '<center>Announcements<center>';
// $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
// $limit_clause = '';
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
// Delete documentation comments above and marked section below
//
// $heading = 'Most Recent Topics You Started';
// $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
// $limit_clause = 'LIMIT 5';
// $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
// Comment out the Info Center's Most Recent Posts Code and Insert this
// to show Most Recent Topics in full detail style instead
//
// $list_count = $settings['number_recent_posts'];
// $heading = 'Most Recently Posted To Topics';
// $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
// $limit_clause = 'LIMIT ' . $list_count;
// $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
if (empty($settings['number_recent_posts']))
$number_recent_posts = 20;
else
$number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
$list_type = $_GET['type'];
else
$list_type = 'last';

        if( isset($_GET['count']) )
$list_count = $_GET['count'];
else
{
$list_count = $number_recent_posts;
if ($list_type == 'notify')
$list_count = 100;
elseif ($list_type == 'hours')
$list_count = 24;
}

if ($list_count <= 0)
{
$list_count = $number_recent_posts;
if ($list_type == 'hours')
$list_count = 24;
}

if ($list_count > 100)
$list_count = 100;

        if( isset($_GET['order']) )
$list_order = $_GET['order'];
else
$list_order = 'lastpost';

        if( $list_order == 'create' )
$order_clause = 't.ID_FIRST_MSG DESC';
else
$order_clause = 't.ID_LAST_MSG DESC';

if ($list_type == 'hours')
{
$list_from = strtotime($list_count.' hours ago');
$where_clause = 'ml.posterTime >= ' . $list_from;
$limit_clause = ' ';
$heading = 'Topics Posted To In Last '. $list_count . ' Hours';
}
elseif ($list_type == 'unreplied')
{
$where_clause = 't.numReplies = 0';
if ($list_count == 0)
{
$limit_clause = ' ';
$heading = 'Unreplied To Topics';
}
else
{
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recent Unreplied To Topics';
}
}
elseif ($list_type == 'notify')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
else
{
$watched_topics = array();
$request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
$heading = $list_count . ' Most Recent Topics Being Watched';
$where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
$limit_clause = 'LIMIT ' . $list_count;
if (empty($watched_topics))
$do_query = 0;
}
}
elseif ($list_type == 'started')
{
if (isset($_GET['user']) && $user_info['is_admin'])
{
$where_clause = 'ms.ID_MEMBER = '.$_GET['user'];
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics Started by User '.$_GET['user'];
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
}
}
else
{
$where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
$limit_clause = 'LIMIT ' . $list_count;
        if( $list_order == 'create' )
{
$order_clause = 't.ID_FIRST_MSG DESC';
$heading = 'Most Recent Topics You Started';
}
else
{
$order_clause = 't.ID_LAST_MSG DESC';
$heading = 'Most Recently Posted To Topics You Started';
}
}
}
else
{
$where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
$limit_clause = 'LIMIT ' . $list_count;
$heading = $list_count . ' Most Recently Posted To Topics';
}
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
ml.subject AS lastSubject, b.memberGroups,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = 'Ã,« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = 'Ã,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' Ã,»';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'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>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
if ($topic['new'] == 0)
{
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


Let me know if it works for you.  BTW, this one doesn't require the extra file that the JA Cortina one does.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on September 24, 2009, 05:43:28 PM
Thanks zarprime used your code and at the present time i only have four post showing in the block..

Any more input would be awesome.
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on September 24, 2009, 05:55:28 PM
Change your Forum to the default SMF theme and check for me how many are shown.

ZP

EDIT:  zapiy, setup a new temp admin account for me so that I can look at your site from inside.  Make sure it's a new account so that all the topics on the Forum will be new.  PM me the details.

2nd Edit:  I gotta say, your site looks perfect with that article as a guest, 20 topics are shown.
Title: Re: "recent topics" in SMF style
Post by: zapiy on September 24, 2009, 09:36:39 PM
pm sent
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on September 24, 2009, 10:46:25 PM
zapiy,

I gotta tell you.  I'm having trouble figuring out why this code is working properly on my site but not on yours.  It shows 20 topics when you aren't logged in but right now, as I am logged in on your site I only see 6 topics.  It really doesn't make any sense.

I'm going to have to take a break on this and look at the code a little closer and see if I can figure it out.  I'll try to get back to this tonight, but it may not be until tomorrow before I can get back on there.  Please keep the account you created active so that I can go back on there if I need to.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on September 25, 2009, 12:02:13 PM
Thanks for all you help on this one. Account still open ..

Cheers
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on September 26, 2009, 12:19:41 PM
zapiy,

I've been through your site with a very fine toothed comb and I can't come up with a reason why this code is not showing 20 topics.  There is a setting in "current theme" that, if it has a number other than zero, will override the setting in the code in this block.  However, it is set to zero in your "current theme" area so it should not be affecting this.

I have a feeling that something else that you have installed is interfering with the ability of this code to work properly..  The next thing I'm going to do is try turning off some of the blocks above this one, one at a time, to see if another block might be causing this.  However, I have stuff to do today and tomorrow that will probably prevent me from getting back into this until either late Sunday night or sometime Monday.

In the meantime, I want to let you know that there is something about your Forum that bothers me, and it could very well be not only affecting this block, but could affect other things in the future.  When viewing your Forum with the default SMF core theme (http://www.maturevideogamer.co.uk/index.php?theme=1) , you have multiple instances of several tabs in your menu (Forum, Gallery, Arcade, Donations).  Have a look at the pic that I have attached below.  This makes it look like you have installed several of your Mods more than once without uninstalling previous versions, and this could be causing conflicts.

If I can't find a reason why this block is not working properly when I get back into it, it may be that your best course of action at some future time is going to be to reinstall SMF without touching the database, thus wiping out all of your Mods, and reinstalling each of the Mods that you are using one at a time.  It might just come down to that, especially given that your error log shows nearly 1000 pages of errors at this time.

If any other Team Members want to take a look at zapiy's site and have a comment about anything I've written here, feel free to take a look.  The theme number currently in use is #6.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on September 26, 2009, 04:00:03 PM
Thanks for your time on this mate...Much appreciated

As for those errors, i am at a loss with it, how simple to reinstall everything? Does the database not have the mods installed in to it aswell?

Title: Re: "recent topics" in SMF style
Post by: zapiy on October 08, 2009, 02:35:16 AM
Wondered if this is simple to rectify? Can i do a clean install and wipe all the mods from the database.
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on October 08, 2009, 03:17:33 AM
zapiy,

Sorry for not getting back to you sooner, been kinda busy.  I still have plans to look at your site again to see if any of your blocks or articles might be causing that one article to not function properly.

I asked the questions we discussed earlier on the team board about the database.  Here's what I found out.

JPDeni said ...
Quote
Usually when the mods create tables the installer first determines if there is a table already in existence. If there is, it skips over the creation of the table. If the installer tries to create a table that already exists, you'll get an error.

Quote from me
"Does the database not have the mods installed in to it aswell?"

Well... The mods are not installed in the database, exactly. Only if there are special tables that are required. But even then most of the mod is in the Source and Themes files, rather than the database.

So the answer to that question would be "Mostly, no." The duplication is in the files and not in the database.

and Ichbin said ...
Quote
Also, when removing a mod the tables do not get removed

So, in essense, generally, what's in the database won't be affected at all if you start over with a fresh install of SMF and then reinstall your Mods.  I would install TP first though because it's probably the largest one.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 19, 2009, 12:25:13 PM
Thanks zarprime, i am looking at completely changing the design on my site and when i do can i guarantee the 20 recent posts will work properly?

Dont want to do a lot of work if it fails to work again.

Cheers
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on October 21, 2009, 04:21:10 PM
zapiy,

Well, it's hard to guarantee anything.  I can tell you one thing.  This block code does not work with TP 1.0 beta 5 on SMF RC1.2 because I've tried it.  It works fine for me on both beta 1 and beta 4 with SMF 1.x.  Before you get into a complete site reset, you might want to setup a test site just to be sure.  I still haven't had a chance to go in and look at your site again to see if one of your other blocks might be causing the problem.  It could be one of your Mods causing the problem because, if I recall correctly, I checked it on your site with the default theme and it was doing the same thing.

I think I might have time this weekend to go into your site and start turning off blocks one at a time to check it.  Do you still have my Admin account active?

The one thing that really has me confused about this is that for Guests, 20 topics are showing, so it's just got to be one of your blocks that is set to not show to guests that has to be causing this.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 23, 2009, 12:27:19 AM
ZarPrime,

You certainly do still have access..again thanks for helping..It does seem strange that the guests see 20 topics all the time.
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 27, 2009, 08:32:04 PM
Zarprime...

This is proper strange, after reinstalling the whole site the other day i added TP1.0 beta 4 then 2 themes and no other mods..

Then i activated the Recent posts block that comes with TP and the posts just keep repeating themselves ie all the same.. If i hit the 'Mark ALL messages as read' link then go back to the frontpage its all good but soon as i read one of them it all goes whacko again..

Tried this on a m8's site and his works fine.

Cheers
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 29, 2009, 10:45:33 PM
bump
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on October 29, 2009, 11:03:26 PM
zapiy,

OK, thanks for bumping the topic.  I couldn't find it.

OK, here's what I want you to do.  I want you to logout of your forum and then click this link ...
http://www.maturevideogamer.co.uk/ssi_examples.php

Right at the top (or just down a little bit) you'll see the "Recent Topics Function" and the "Recent Posts Function" right below it.  If you look carefully, at the Recent Topics you'll notice that every one of those is unique when viewed as a Guest.  However, if you look at the Recent Posts, you'll probably see that there is at least 1 post that is listed more than once.  This is how it should appear not only when you are looking as a Guest but when you ar logged in as well.

OK, now, go back to your site and login.  Read the first new topic but leave the rest of the topics unread.  Now, when you stay logged in, click this link again ...
http://www.maturevideogamer.co.uk/ssi_examples.php

Though each listed topic in the Recent Topics function should be unique, you are probably going to see multiples (look at the attached image below ~ this is what I saw the other day).  I believe this is the source of your problem and I am almost positive that this is what caused that block code I gave you a while back to not be working properly.

So, now, what to do?  Well, since your host is familiar with SMF, you could explain to him what's going on and just tell him that the "Recent Topics Function" is not working right and ask him if he has any idea why.  The bottom line is that I am nearly 100% certain that this is an SMF issue.  It has nothing to do with TP.  However, I have talked to Ichbin as well on this and he is also going to do some research on it as well.

If you can't get a suitable answer from your host on this, I suggest you post at SMF directly in the SMF 1.0 Support board.  Feel free to reference this post in your topic over there.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 29, 2009, 11:09:09 PM
Thanks zarprime..I will ask the guys at smfhelper..

Go from there..
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on October 29, 2009, 11:15:32 PM
Report back. Bro'.  I'd like to see you get this problem fixed once and for all. ;)

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 30, 2009, 02:22:49 PM
Thanks Fella, just wanted to say a massive thanks to Zarprime on the open forum.. Not often someone is as helpful as you fella and as far as i am concern a massive plus for Tinyportal.net...

Cheers

Will report back asap..
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 31, 2009, 04:53:40 PM
Ok zarprime, Bigguy has said there is no issue on the php side of the server as all there sites are fine..Sounds ok to me so i guess there is an issue with my database.

Can i backup the database with only the forum data and users..ie dropping any info relating to the mods..

Cheers
Title: Re: "recent topics" in SMF style
Post by: IchBin on October 31, 2009, 06:30:02 PM
Of course, if you have phpMyAdmin you can go to the export tab. Select the tables you want in the select box, then export the data leaving off any mod tables.
Title: Re: "recent topics" in SMF style
Post by: zapiy on October 31, 2009, 10:13:51 PM
Ichbin, zarprime mention you are bit of a wiz on databases..could you list the tables i need to export as there are loads and i dont know which i need.
Title: Re: "recent topics" in SMF style
Post by: IchBin on November 01, 2009, 01:33:09 AM
This should be the only db tables on a SMF 1.1.10 site I think. You should make a complete backup of all tables before you do anything though. :D

smf_attachments
smf_banned
smf_ban_groups
smf_ban_items
smf_boards
smf_board_permissions
smf_calendar
smf_calendar_holidays
smf_categories
smf_collapsed_categories
smf_im_recipients
smf_instant_messages
smf_log_actions
smf_log_activity
smf_log_banned
smf_log_boards
smf_log_errors
smf_log_floodcontrol
smf_log_karma
smf_log_mark_read
smf_log_notify
smf_log_online
smf_log_polls
smf_log_search_messages
smf_log_search_results
smf_log_search_subjects
smf_log_search_topics
smf_log_topics
smf_membergroups
smf_members
smf_messages
smf_message_icons
smf_moderators
smf_package_servers
smf_permissions
smf_personal_messages
smf_pm_recipients
smf_polls
smf_poll_choices
smf_sessions
smf_settings
smf_smileys
smf_themes
smf_topics
Title: Re: "recent topics" in SMF style
Post by: zapiy on November 02, 2009, 07:51:00 PM
I am having a mare with this, just keeps giving errors?
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on November 03, 2009, 01:35:10 AM
Quote from: zapiy on October 27, 2009, 08:32:04 PM
Zarprime...

This is proper strange, after reinstalling the whole site the other day i added TP1.0 beta 4 then 2 themes and no other mods..

Then i activated the Recent posts block that comes with TP and the posts just keep repeating themselves ie all the same.. If i hit the 'Mark ALL messages as read' link then go back to the frontpage its all good but soon as i read one of them it all goes whacko again..

Tried this on a m8's site and his works fine.

Cheers

zapiy,

I'd like you to do something for me.  Please setup a test site with a totally new install (new database) and have your Admins and Moderators, and anyone else you want, to join the test site and start posting.  Meanlingness posts are OK since it's just a test site.  Set it up exactly like you have you current site set up with the same blocks, etc. and see if the same thing happens on the test site.  Make sure you install SMF, then TP, then your 2 themes, in that order.  If it happens on the test site, then it obviously has something to do with your host.  If the same problems with the recent topics don't occur then it is obviosly your database.  Once you have done this, we can decide what to do next.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on November 04, 2009, 07:23:11 AM
Jim,

I just went for it last night and exported the default tables and imported them to a new database....And guess what all seems to work..

Wondered if you would help me with some errors i now have since..

Thanks fella
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on November 04, 2009, 02:18:22 PM
Sure, we can help you with those, but for now, let's take it out of this topic.  Why don't you start a new topic in the support board for the errors and let's see what we can do to get you fixed up.  That will move us away from having further discussions about the code from the OP in this topic and place the emphasis on your errors.  It will also allow others to help out if they choose to do so, since most of them, except Ichbin that is, had no idea what we've been discussing on your problems.

First, post a new topic in the support board, and follow the posting guidelines so that everybody will know where your site is and we can go from there.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on November 04, 2009, 10:46:44 PM
Using your recent code you post earlier and i seem to have some issues..

Are they just the way its setup?
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on November 05, 2009, 06:30:57 PM
zapiy,

What issues?  I'll see if I can get some time a little later today to take a look at your site and see if I can figure out what you mean.

ZarPrime

Edit:  OK, I went ahead and looked at your site.  The same thing is happening with the recent topics function that was happening before (take a look at the attached image).  At this point, I think you need to go over to SMF and ask them why this is happening on your site and what can be done to fix it.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: zapiy on November 06, 2009, 08:02:13 AM
Is very annoying and strange this seems to only ever happened to me..  I have asked bigguy to look into it for me as i hope we can sort it.
Title: Re: "recent topics" in SMF style
Post by: uniektekniek on December 16, 2009, 11:25:41 PM
hey all.. nice script... but i cant seem to get the targeted boards working.. its still showing the most recent topics from the whole forum rather than just selected boards

what am I doing wrong?


       
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', array('1','112','47','52','36','49','37','51','192','8') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: "recent topics" in SMF style
Post by: IchBin on December 17, 2009, 12:20:39 AM
The boards you put in the array are boards that are excluded. You need to put the boards in the array that you don't want recent topics to come from. Or pick another recentTopics code snippet that does what you want.
Title: Re: "recent topics" in SMF style
Post by: uniektekniek on December 17, 2009, 12:24:42 AM
ah excellent... thats actually way easier for me... as you can probably tell my forum is fair large... theres only really 3 boards i wanna hide...

thanks for your help!
Title: Re: "recent topics" in SMF style
Post by: uniektekniek on December 17, 2009, 12:31:25 AM
one last quick question... is it possible to set this so the threads stay showing for more than 10 hours or so? eg the last 10 threads no matter how long ago it was?
Title: Re: "recent topics" in SMF style
Post by: IchBin on December 17, 2009, 10:51:06 PM
Not with the recentTopics codes we have right now. I'd bet you'd need to change something in it, or write a new one. If one of the other coders can't get to it, I'll take a look later.
Title: Re: "recent topics" in SMF style
Post by: uniektekniek on January 18, 2010, 06:42:07 AM
has anyone been able to have a look into this... or possibly point me in the direction of another block that may hold onto posts a little longer?
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on January 18, 2010, 03:03:13 PM
uniektekniek,

Try the one that I posted in this message to see if it will do what you want ...
http://www.tinyportal.net/index.php?topic=596.msg247350#msg247350

On my site, using this configuration, topics are shown no matter how old they are.  If you want to exclude those 3 boards, you will need to gro through the configuration.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: Rav33n on February 21, 2010, 10:03:46 AM
I want to edit this code to show topics from 1 board only. I have tried replacing recentTopics with BoardNews, but I can't get the formatting and linking correct - please help.

This is what I have tried:


global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_boardNews($board = 9.0, $limit = 15, $start = null, $length = 250, $output_method = 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">
                                                ', $topic['subject'], '</a>';

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


This currently gives me links like http://XX/index.php/topic,.from.html#new

Help! :)
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on February 21, 2010, 05:18:58 PM
Rav33n,

I'm not sure what you are trying to do.  The code shown below placed into a php block will show the most recent post in the 3 most recent topics in 2 different boards on your site.  Maybe looking through this code will help you to figure out whatever it is you are trying to do.

ZarPrime


$result=ssi_recentTopics(3,array(2,3,4),'return');
echo '<span class="smalltext">Last Post from Board #1</span>';
echo '<ul style="margin-left: 2px;">';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
}
echo '</ul>';
echo '<hr>';
$result=ssi_recentTopics(3,array(1,3,4),'return');
echo '<span class="smalltext">Last Post from Board #2</span>';
echo '<ul style="margin-left: 2px;">';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
}
echo '</ul>';
Title: Re: "recent topics" in SMF style
Post by: Rav33n on February 21, 2010, 09:32:19 PM
I went through the SSI documentation and if I understood correct, using recentTopics I can only eliminate boards that I don't want to show, right? In my case, I have too many boards (and keep adding boards) so that will be impossible. I want to be able to display recent topics from just one board... and another thread suggested I use boardNews.

Is there a way I can get topics from just one board without having to exclude each and every other board in the parameters?

Thanks for the reply.
Title: Re: "recent topics" in SMF style
Post by: Mick on February 21, 2010, 11:58:04 PM
ZP,....i believe you created this code.   Is it possible to convert it to RC2?

The feature im looking for is to show topics/posts in the last 24 hours adn this script has it.

Thanx man.

Mick.

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//   
   $exclude_boards = array();   // KEEP (to preserve variable declaration)
//   $exclude_boards = array(5);   //  Exclude single board
//     $exclude_boards = array(55,69);   //  Exclude multiple boards
   $ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//   
//   

//////////////////////////////////////////// ---------- Use in TP PHP Article (no title or frame from theme)
//   This will give most recent XX posted to topics -OR-
//   most recent XX unreplied to topics -OR-
//   topics posted to in last XX hours -OR-
//   most recent XX topics on topic notify list
//   
//   Sorts by most recent reply (descending; most recent first) -OR-
//            creation order (descending; most recent first)
//   
//   All in the detailed topic format
//   
//   
//   Default
//   index.php?page=##
//   most recent posted to topics - will list
//   number equal to  $settings['number_recent_posts']
//   
//   index.php?page=##;count=50 or index.php?page=##;type=last;count=50
//   50 most recently posted to topics
//   
//   index.php?page=##;type=unreplied or index.php?page=##;type=unreplied;count=50
//   Most recent unreplied to topics - will
//   list number specified in 'count' or default to
//   number equal to  $settings['number_recent_posts']
//   
//   index.php?page=##;type=hours or index.php?page=##;type=hours;count=12
//   Topics posted to in last number of hours
//   specified in 'count' or default to 24.
//   
//   index.php?page=##;type=notify or index.php?page=##;type=notify;count=50
//   Topics in topic notifcation list up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   *** Admins Only ***
//   index.php?page=##;type=notify;user=XXX or index.php?page=##;type=notify;user=XXX;count=50
//   Topics in topic notifcation list of specified user up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   index.php?page=##;type=started or index.php?page=##;type=started;count=50
//   Topics started by current user list up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   *** Admins Only ***
//   index.php?page=##;type=notify;user=XXX or index.php?page=##;type=started;user=XXX;count=50
//   Topics started by specified user up to number
//   specified in 'count' or a maximum of 100 topics.
//   
//   Add argument order=create to sort by topic creation sequence (most recent first)
//   rather than by last reply sequence

   $do_query = 1;

//////////////////////////////////////////// ---------- Poor Man's Global Announcements Block (center block - no Title/Frame)
//   Delete documentation comments above and marked section below
//
//   $announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
//
//   $heading = '<center>Announcements<center>';
//   $where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
//   $limit_clause = '';
//   $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Last 5 Topics Started by User Block (center block - no Title/Frame)
//   Delete documentation comments above and marked section below
//
//   $heading = 'Most Recent Topics You Started';
//   $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
//   $limit_clause = 'LIMIT 5';
//   $order_clause = 't.ID_FIRST_MSG DESC';
////////////////////////////////////////////   

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
//   Comment out the Info Center's Most Recent Posts Code and Insert this
//   to show Most Recent Topics in full detail style instead
//
//   $list_count = $settings['number_recent_posts'];
//   $heading = 'Most Recently Posted To Topics';
//   $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 50 * min($list_count, 5));
//   $limit_clause = 'LIMIT ' . $list_count;
//   $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////   

////////////////////////////////////////////  ------ Remove down to next mark to use in block/boardindex ------
//
   if (empty($settings['number_recent_posts']))
      $number_recent_posts = 20;
   else
      $number_recent_posts = $settings['number_recent_posts'];

        if( isset($_GET['type']) )
      $list_type = $_GET['type'];
   else
      $list_type = 'last';

        if( isset($_GET['count']) )
      $list_count = $_GET['count'];
   else
   {
      $list_count = $number_recent_posts;
      if ($list_type == 'notify')
         $list_count = 100;
      elseif ($list_type == 'hours')
         $list_count = 24;
   }

   if ($list_count <= 0)
   {
      $list_count = $number_recent_posts;
      if ($list_type == 'hours')
         $list_count = 24;
   }

   if ($list_count > 100)
      $list_count = 100;

        if( isset($_GET['order']) )
      $list_order = $_GET['order'];
   else
      $list_order = 'lastpost';

        if( $list_order == 'create' )
      $order_clause = 't.ID_FIRST_MSG DESC';
   else
      $order_clause = 't.ID_LAST_MSG DESC';

   if ($list_type == 'hours')
   {
      $list_from = strtotime($list_count.' hours ago');
      $where_clause = 'ml.posterTime >= ' . $list_from;
      $limit_clause = ' ';
      $heading = 'Topics Posted To In Last '. $list_count . ' Hours';
   }
   elseif ($list_type == 'unreplied')
   {
      $where_clause = 't.numReplies = 0';
      if ($list_count == 0)
      {
         $limit_clause = ' ';
         $heading = 'Unreplied To Topics';
      }
      else
      {
      $limit_clause = 'LIMIT ' . $list_count;
      $heading = $list_count . ' Most Recent Unreplied To Topics';
      }
   }
   elseif ($list_type == 'notify')
   {
      if (isset($_GET['user']) && $user_info['is_admin'])
      {
         $watched_topics = array();
         $request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$_GET['user']} AND ID_BOARD = 0", __FILE__, __LINE__);
         while ($row = mysql_fetch_assoc($request))
            $watched_topics[] = $row['ID_TOPIC'];
         mysql_free_result($request);
         $heading = $list_count . ' Most Recent Topics Being Watched by User # '.$_GET['user'];
         $where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
         $limit_clause = 'LIMIT ' . $list_count;
         if (empty($watched_topics))
            $do_query = 0;
      }
      else
      {
         $watched_topics = array();
         $request = db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$ID_MEMBER} AND ID_BOARD = 0", __FILE__, __LINE__);
         while ($row = mysql_fetch_assoc($request))
            $watched_topics[] = $row['ID_TOPIC'];
         mysql_free_result($request);
         $heading = $list_count . ' Most Recent Topics Being Watched';
         $where_clause = 't.ID_TOPIC IN (' . implode(', ', $watched_topics) . ')';
         $limit_clause = 'LIMIT ' . $list_count;
         if (empty($watched_topics))
            $do_query = 0;
      }
   }
   elseif ($list_type == 'started')
   {
      if (isset($_GET['user']) && $user_info['is_admin'])
      {
         $where_clause = 'ms.ID_MEMBER = '.$_GET['user'];
         $limit_clause = 'LIMIT ' . $list_count;
              if( $list_order == 'create' )
         {
            $order_clause = 't.ID_FIRST_MSG DESC';
            $heading = 'Most Recent Topics Started by User '.$_GET['user'];
         }
         else
         {
            $order_clause = 't.ID_LAST_MSG DESC';
            $heading = 'Most Recently Posted To Topics Started by User '.$_GET['user'];
         }
      }
      else
      {
         $where_clause = 'ms.ID_MEMBER = '.$ID_MEMBER;
         $limit_clause = 'LIMIT ' . $list_count;
              if( $list_order == 'create' )
         {
            $order_clause = 't.ID_FIRST_MSG DESC';
            $heading = 'Most Recent Topics You Started';
         }
         else
         {
            $order_clause = 't.ID_LAST_MSG DESC';
            $heading = 'Most Recently Posted To Topics You Started';
         }
      }
   }
   else
   {
      $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * min($list_count, 5));
      $limit_clause = 'LIMIT ' . $list_count;
      $heading = $list_count . ' Most Recently Posted To Topics';
   }
//
////////////////////////////////////////////  ------ Remove up to first mark to use in block/boardindex ------

   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';

   $groupcolors = array();
   $request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
   while ($row = mysql_fetch_assoc($request))
      $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
   mysql_free_result($request);

   $topics = array();

   if ($do_query == 1)
   {
   $request = db_query("
      SELECT
            ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
            t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
            ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
            IFNULL(meml.realName, ml.posterName) AS lastPosterName,
            mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
            ml.subject AS lastSubject, b.memberGroups,
            ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
            LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
            ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
            . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
            IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
            IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
         FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
            LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
            LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
            LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
            LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
         WHERE " . $where_clause . $ex_board_clause . "
            AND t.ID_TOPIC = ms.ID_TOPIC
            AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
            AND ms.ID_MSG = t.ID_FIRST_MSG
            AND ml.ID_MSG = t.ID_LAST_MSG
            AND " . $user_info['query_see_board'] . "
         ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


   $topic_ids = array();
   while ($row = mysql_fetch_assoc($request))
   {
      if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
         continue;

      $topic_ids[] = $row['ID_TOPIC'];

      // Clip the strings first because censoring is slow :/. (for some reason?)
      $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
      if (strlen($row['firstBody']) > 128)
         $row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
      $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
      if (strlen($row['lastBody']) > 128)
         $row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

         $row['lastSubject'] = $row['firstSubject'];
         $row['lastBody'] = $row['firstBody'];

      // Decide how many pages the topic should have.
      $topic_length = $row['numReplies'] + 1;
      if ($topic_length > $modSettings['defaultMaxMessages'])
      {
         $tmppages = array();
         $tmpa = 1;
         for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
         {
            $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
            $tmpa++;
         }
         // Show links to all the pages?
         if (count($tmppages) <= 5)
            $pages = 'Ã,« ' . implode(' ', $tmppages);
         // Or skip a few?
         else
            $pages = 'Ã,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

         if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
            $pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
         $pages .= ' Ã,»';
      }
      else
         $pages = '';

      // We need to check the topic icons exist... you can never be too sure!
      if (empty($modSettings['messageIconChecks_disable']))
      {
         // First icon first... as you'd expect.
         if (!isset($icon_sources[$row['firstIcon']]))
            $icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
         // Last icon... last... duh.
         if (!isset($icon_sources[$row['lastIcon']]))
            $icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
      }

      $color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
      $color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

      // And build the array.
      $topics[$row['ID_TOPIC']] = array(
         'id' => $row['ID_TOPIC'],
         'first_post' => array(
            'id' => $row['ID_FIRST_MSG'],
            'member' => array(
               'name' => $row['firstPosterName'],
               'id' => $row['ID_FIRST_MEMBER'],
               'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
               'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
            ),
            'time' => timeformat($row['firstPosterTime']),
            'timestamp' => forum_time(true, $row['firstPosterTime']),
            'subject' => $row['firstSubject'],
            'preview' => $row['firstBody'],
            'icon' => $row['firstIcon'],
            'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
            'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
            'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
         ),
         'last_post' => array(
            'id' => $row['ID_LAST_MSG'],
            'member' => array(
               'name' => $row['lastPosterName'],
               'id' => $row['ID_LAST_MEMBER'],
               'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
               'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
            ),
            'time' => timeformat($row['lastPosterTime']),
            'timestamp' => forum_time(true, $row['lastPosterTime']),
            'subject' => $row['lastSubject'],
            'preview' => $row['lastBody'],
            'icon' => $row['lastIcon'],
            'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
            'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
            'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
         ),
         'new' => $row['isRead'],
         'new_from' => $row['new_from'],
         'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
         'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
         'is_locked' => !empty($row['locked']),
         'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
         'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
         'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
         'is_posted_in' => false,
         'icon' => $row['firstIcon'],
         'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
         'subject' => $row['firstSubject'],
         'pages' => $pages,
         'replies' => $row['numReplies'],
         'views' => $row['numViews'],
         '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>'
         )
      );

      determineTopicClass($topics[$row['ID_TOPIC']]);
   }
   mysql_free_result($request);

   if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
   {
      $result = db_query("
         SELECT ID_TOPIC
         FROM {$db_prefix}messages
         WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
            AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
      while ($row = mysql_fetch_assoc($result))
      {
         if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
         {
            $topics[$row['ID_TOPIC']]['is_posted_in'] = true;
            $topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
         }
      }
      mysql_free_result($result);
   }

   }

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
            <tr class="titlebg">
               <td width="10%" colspan="2"> </td>
               <td>', $txt[70], '
               </td><td width="14%">', $txt[109], '
               </td><td width="4%" align="center">', $txt[110], '
               </td><td width="4%" align="center">', $txt[301], '
               </td><td width="24%">', $txt[111], '
               </td>
            </tr>';

   foreach ($topics as $topic)
   {
      // Do we want to seperate the sticky and lock status out?
      if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
         $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
      if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
         $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

      echo '
            <tr>
               <td class="windowbg2" valign="middle" align="center" width="6%">
                  <img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
               </td><td class="windowbg2" valign="middle" align="center" width="4%">
                  <img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
               </td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
                  <img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
                  <img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
               if ($topic['new'] == 0)
                  {
                  echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
                  }
                echo '
               <span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
               <td class="windowbg2" valign="middle" width="14%">
                  ', $topic['first_post']['member']['link'], '</td>
               <td class="windowbg" valign="middle" width="4%" align="center">
                  ', $topic['replies'], '</td>
               <td class="windowbg" valign="middle" width="4%" align="center">
                  ', $topic['views'], '</td>
               <td class="windowbg2" valign="middle" width="22%">
                  <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
                  <span class="smalltext">
                     ', $topic['last_post']['time'], '<br />
                     ', $txt[525], ' ', $topic['last_post']['member']['link'], '
                  </span>
               </td>
            </tr>';
   }

    echo '</table></div>';

    }
   else
       echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on February 22, 2010, 04:51:24 PM
Mick,

Actually, no, I'm not the one who created that code.  I don't remember who originally wrote it but I posted it somewhere here when someone asked what the code was that I use on one of my sites.  I appreciate the vote of confidence but I'm really not much of a coder.  I have gotten pretty good at troubleshooting code written by others and have even converted a couple of code snippets to work with SMF 2.0 RC2 for my own use, but I haven't spent enough time to teach myself the actual intricacies of writing code yet.

All that being said, this code is probably one of the ones that I will work on a little later because I will need it.  The problem I see with doing that right now is that, now that SMF 2.0 RC3 is known to be not too far off, I don't relish the thought of editing this code for RC2, only to find out that it won't work with RC3.  Combine that with the fact that we are heavily into working out the bugs for TP 1.0 beta 5 and you might understand why I am going to choose to not work on this, at least not yet.

Once TP 1.0 beta 5 is out to the public, I expect that converting some of the existing code snippets is going to occupy a lot of our time for awhile but since  it hasn't been released yet, it's not high on my priority list.  Perhaps JPDeni or Freddy would be willing to take this on before I can but it shouldn't be a priority at this point for you either, unless you are just wanting to use this code on your (non-TP) site. :buck2:  If that's the reason you want it now, I hope you'll understand that this is another reason why I'm not too excited about updating this yet. ;)

Bear with me.  If I get a chance to look at it this weekend, I may take the time to go through the code and see what I can do.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: Mick on February 22, 2010, 07:02:27 PM
ZP, i understand completely ;)

I also waiting for TP5.  Reason i use the other simply because my pages/articles are vital.


...but yes,  this script sure is one that i really like and i'll wait for it whenever becomes available.  :smitten:


Thanx for responding ;)

Title: Re: "recent topics" in SMF style
Post by: IchBin on February 22, 2010, 07:54:10 PM
Blue, I just did a quick update of the code. I don't know if it works because I don't have any where to test it at the moment. Please go to this topic while we work on this.

http://www.tinyportal.net/index.php?topic=31950.0
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 23, 2010, 07:10:50 PM
Hello.

I pasted the following into a php box twice ( two boxes ):

       
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', array('1','112','47','52','36','49','37','51','192','8') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


The result is in attachement.

I wonder if anyone happens to know how I can make those two boxes the same length.. for some reason the left one has a longer length as the right box.

Thanks!

EDIT: I noticed they change with the size of the title.. is there any way to implement a length which it sticks to?
Title: Re: "recent topics" in SMF style
Post by: Rav33n on March 23, 2010, 07:24:35 PM
ricardo3523 your problem is with the block width and not the code itself.

Make both block widths the same and see whether the lengths match.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 23, 2010, 07:29:13 PM
Sorry for my confusing post.

I confused length with width..

I would like to know how I can make both blocks have the same width.
And I am unable to find any option which says blocks width..
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 23, 2010, 09:58:52 PM
Then perhaps you should tell us which verison of TP you're using. There are all sorts of width options in the latest beta inside the panel and block options area.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 23, 2010, 10:01:51 PM
Quote from: ricardo3523 on March 23, 2010, 07:29:13 PM
Sorry for my confusing post.

I confused length with width..

I would like to know how I can make both blocks have the same width.
And I am unable to find any option which says blocks width..

I'm not familiar with the version you are using, as I don't have time to back read all of the posts. There are a few ways to do this.

First i would try going to the panel settings and you can set the width of each block within the panel. This way all blocks have the same width regardless.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 23, 2010, 11:46:59 PM
I believe I have TP 1.0...
I've got no clue where I can check my TP version, only managed to find my SMF version.

The only width option at panels at those blocks are ''Padding between panels:      ''
So, for as far I see, no option to set a width.
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 24, 2010, 02:27:30 AM
TP version is always in the footer. If you don't see it in a custom theme, then check the default theme. Sounds like you are running TP 0.9.8 though if you don't see any other options. That old version doesn't have these features.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 24, 2010, 03:21:58 AM
Yes, it sounds like you are using an older version if you don't have that option.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 24, 2010, 08:13:36 AM
So I suppose there is no way to make a set width for those blocks then?

Would it be possible to upgrade the TP version without screwing anything from the website over?
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 24, 2010, 01:14:35 PM
There's no guarantee for anything. I haven't see any site blow up because of TP. However, there shouldn't be any worry if you have backups before you upgrade. However, if you're that concerned about it I would install it on a test site and test it out before upgrading if I were you.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 25, 2010, 03:55:14 PM
There are a few other ways, but I couldn't just write up the script for you right here. I would have to go and play with it, which I don't have time right now.

Is your site at a set width, or is it fluid?

If it's a set width, you can just set the width of the bocks. Otherwise trying applying width percentages to all the tablecells of the block.

like I said, it would require some experimentation.

Try:

FIND:

                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];


REPLACE WITH:

                                        <td class="windowbg" valign="middle" width="45%">
                                                ', $topic['link'];


That should be in the code anyways.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 28, 2010, 09:18:48 AM
For some reason my account was deleted?

Anyways..
To Ichbin, I tried installing the 1.0 beta 4 TP with the package installer but it said I already had the same version.. so I suppose I should be able to set a width for the blocks??

To Xarcell, I implemented the code, and it moved the widths around a bit, but still with equal numbers the one with the largest text in its box was displaying larger.
Title: Re: "recent topics" in SMF style
Post by: ZarPrime on March 28, 2010, 02:53:06 PM
ricardo3523,

The deletion of your account was unfortunate.  Sorry this happened.  It is likely that this was due to Bloc's recent move to a newer and more powerful server.  I would guess that you joined up quite recently and the backup that Bloc used to restore the Forum was somehow missing not only your account information but possibly a few others.  Anyway, I'm glad you found your way back in.

Anyway, back to your issue.  Did you do the upgrade to TP 1.0 beta 4 without uninstalling TP 0.98 first?  Can you please give us a link to your site that shows the behavior you are talking about so that we can see it in action.  Actually, a screenshot of the panel Admin section for the particular panel you are using would be nice as well.  While you are at it, it might be best to use the posting template in the Posting Guidelines (http://www.tinyportal.net/index.php/topic,581) to tell us as much about your site as you can.

ZarPrime
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 28, 2010, 04:07:45 PM
@ ricardo3523

Can I see the example you are using at your site? I need to see an live example of what your trying to do.

Sorry about your account being deleted. Bloc moved servers and we lost some stuff during the move.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 28, 2010, 07:20:56 PM
@ZarPrime.  No I did not tried to uninstall any previous TP version.

Link to my site: www.hyperion-legion.com
SMF version: Forum version: SMF 1.1.11
Current SMF version: SMF 1.1.11
TP version: No idea.
Theme name and version: AionRed
Browser Name and Version: Mozzila firefox..
Mods installed: Aside from gallery that came with the hosting, none.
Related Error messages: None.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 28, 2010, 09:56:41 PM
So your trying to place to recent topic blocks side by side in a upper panel block?

Untested, but try:
global $scripturl;

echo '
<div style="position: relative; padding: 0px; margin: 0px;">';
  echo '
      <div style="position: absolute; left: 0px; top: 0px; width: 49%;">';

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', array('1','112','47','52','36','49','37','51','192','8') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
          echo '</div>';
         
          echo '
                <div style="position: absolute; right: 0px; top: 0px; width: 49%;">';
                                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', array('1','112','47','52','36','49','37','51','192','8') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
                       
                   echo '</div>';
    echo '</div>';


Adjust the array to your board ID's. Let me know if it works.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 29, 2010, 07:31:01 AM
QuoteParse error: syntax error, unexpected '<' in /home/ensidial/public_html/Sources/Load.php(1742) : eval()'d code(52) : eval()'d code on line 49

Currently being displayed on the spot where the block should appear.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 29, 2010, 08:07:48 AM
Quote from: ricardo3523 on March 29, 2010, 07:31:01 AM
QuoteParse error: syntax error, unexpected '<' in /home/ensidial/public_html/Sources/Load.php(1742) : eval()'d code(52) : eval()'d code on line 49

Currently being displayed on the spot where the block should appear.


oops.  use this instead.

global $scripturl;

echo '
<div style="position: relative; padding: 0px; margin: 0px;">';
  echo '
      <div style="position: absolute; left: 0px; top: 0px; width: 49%;">';

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', array('1','112','47','52','36','49','37','51','192','8') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
          echo '</div>';
         
          echo '
                <div style="position: absolute; right: 0px; top: 0px; width: 49%;">';
               
                echo '
                                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', array('1','112','47','52','36','49','37','51','192','8') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                                                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
                       
                   echo '</div>';
    echo '</div>';
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 29, 2010, 08:12:55 AM
Implemented it in both blocks. Result in attachement.
When I just did it with one block the other block ( so in different code ) was displayed behind it, as you see the front page posts now behind those blocks, suddenly it are four.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 29, 2010, 08:21:51 PM
The code I gave only needs one block, or posted once.

Also, you may need to add a height to the first div in the script.

ex: <div style="position: relative; height: 500px; padding: 0px; margin: 0px;">';
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 29, 2010, 08:52:51 PM
Ok, thanks for clarifying that :)

It works.. however the website does not notice it as a block..
As in the previous screenshot, you see the other blocks behind these two.

I'm not sure what you mean with:
Quote<div style="position: relative; height: 500px; padding: 0px; margin: 0px;">';
I don't know where to implement this :)
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 29, 2010, 10:40:32 PM
Ok, well I understand it now. I placed the width inside the div bar.
Result is (first attachement) that it works. However of course I want to remove the frame from the block, as this script already has got its frame. But after removing the frame, I get the following ( attachement 2 )
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 30, 2010, 04:54:03 AM
Tpo remove the frame, go to the block option and select "don't show frame/title".
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 30, 2010, 08:28:23 AM
That's what I am doing :P
When I remove the frame+title, I get the result in the second attachement.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 30, 2010, 09:45:17 PM
So uhmm yea.. I don't know what to  do now. :o
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 30, 2010, 09:50:34 PM
I've looked at your site in IE8, FF 3.0.10, and Chrome 4.1.249.1036 beta (41514).

It looks fine in all 3 browsers. What browser are you using, and does it happen with any other browsers you have?
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 30, 2010, 09:54:07 PM
Yes, you're right. It is working fine.
However I want to get rid of the double background/frame.
So therefore I select the box to not show frame+title.

After selecting that box, I get the result as u see in attachement 2 from my previous post. The 2 blocks from the code do strange.

---
I selected the do not show frame+title now, so you can see it :)
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 30, 2010, 09:57:03 PM
I see now. Looks like there is an extra <td> when you do that. Let me see if I can replicate the problem. Are you using the code that was last posted by Xarcell?
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 30, 2010, 10:41:31 PM
Yes, I am sure I am using his last posted code.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 31, 2010, 05:24:25 AM
...
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 31, 2010, 05:33:07 AM
Quote from: IchBinâ„¢ on March 30, 2010, 09:57:03 PM
I see now. Looks like there is an extra <td> when you do that. Let me see if I can replicate the problem. Are you using the code that was last posted by Xarcell?

I see the extra TD too Ich.

Lol, is that TP? is that the one that bikken found awhile back?

I'm still trying to figure out where that background color is coming from though. It doesn't make sense. I'd swear that it's the frame background.

EDIT:
I'm looking at the code right now and it's using "windowbg", the same as the other blocks.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 31, 2010, 08:54:08 AM
Thought I'd just let you know, also if I only choose to not display the title, it starts doing a bit odd.
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 31, 2010, 03:00:08 PM
Can you try this code to see if it does anything different?
global $scripturl, $settings, $txt, $context;

echo '
<div style="width: 50%; float: left;">';

echo '
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
   <tr><td colspan="3" class="titlebg">Recent topics</td></tr>';
   
$what=ssi_recentTopics(8, array(2), 'array');

        foreach ($what as $topic)
        {
echo '
<tr>
<td class="windowbg" valign="middle">
', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                        echo '
                    <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
</td>
<td class="windowbg2" valign="middle" width="20%">
', $topic['poster']['link'], '
</td>
<td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="last post" title="last post" border="0" style="float: right;" /></a>
<span class="smalltext">
', $topic['time'], '
</span>
</td>
</tr>';
        }

        echo '
</table>
</div>
    <div style="float: right; width: 50%;">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr><td colspan="3" class="titlebg">Recent topics</td></tr>';

$what=ssi_recentTopics(8, array(3), 'array');

        foreach ($what as $topic)
        {
echo '
<tr>
<td class="windowbg" valign="middle">
', $topic['link'];

                // Is this topic new? (assuming they are logged in!)
                if (!$topic['new'] && $context['user']['is_logged'])
                    echo '
                <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
</td>
<td class="windowbg2" valign="middle" width="20%">
', $topic['poster']['link'], '
</td>
<td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="last post" title="last post" border="0" style="float: right;" /></a>';
               
                echo '
<span class="smalltext">
', $topic['time'], '
</span>
</td>
</tr>';
        }

        echo '
</table>
</div>';
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 31, 2010, 03:38:53 PM
It seems to be working ;)

Well, thank you both I guess!!

Just one remaining question, how can I get the left side of the frame from this code on the same row as from the news that shows beneath it.

Tried some numbers in the code itself and on the admin panel, didn't managed to find anything yet.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi42.tinypic.com%2F2hx4l12.jpg&hash=0846986573820fdfb5bae6c38a96fea0c955048d)
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 31, 2010, 07:53:58 PM
Do you still have another block enabled? It looks to me like that extra <td> causing your shift on the left is from an empty block or something. I can't reproduce the same affect on my site.
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 31, 2010, 07:55:42 PM
Quote from: IchBinâ„¢ on March 31, 2010, 07:53:58 PM
Do you still have another block enabled? It looks to me like that extra <td> causing your shift on the left is from an empty block or something. I can't reproduce the same affect on my site.

I think it's TP. It's an extra TD. Bloc has corrected this in beta 5.
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 31, 2010, 07:56:31 PM
Doesn't happen on my TP beta 4 or beta 5.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 31, 2010, 07:58:45 PM
I don't have any other upper blocks enabled or front page blocks.

There is an option at those blocks saying padding between panels.. but this is on #4 at every block.. so that can't be it?
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 31, 2010, 08:03:00 PM
Need to know your TP version. Would help if you'd leave the version in your footer. :) Would you mind letting me take a look? I can't reproduce the issue on my setup. I don't think the padding has anything to do with it.
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 31, 2010, 08:10:14 PM
Well if you would be able to tell me where I can find my TP version I'd be glad to look it up for you :)
What do you mean exactly, letting you take a look?
Title: Re: "recent topics" in SMF style
Post by: Xarcell on March 31, 2010, 08:17:20 PM
Quote from: ricardo3523 on March 31, 2010, 08:10:14 PM
Well if you would be able to tell me where I can find my TP version I'd be glad to look it up for you :)
What do you mean exactly, letting you take a look?

Look in your admin > packages
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 31, 2010, 08:41:26 PM
Tinyportal:  1.083
Title: Re: "recent topics" in SMF style
Post by: ricardo3523 on March 31, 2010, 09:15:30 PM
K sooo..

At upper panels ( which this one is ) I had display blocks in 2 collums checked.
I changed to display vertically (default) and for some reason the block went to the same line as the news blocks beneath it..

However.. now ( as you can see ) the right block sticks directly to the news blocks beneath it.. How can that be solved ><

Edit: If I choose '' display according to a grid''   it displays the same as in default but the area beneath the two upper blocks and the block beneath it is kinda huge... There is more space as in the default one.. However here the width is perfect.. 

Soo er... I've run out of thoughts..

Maybe you could tell me your tinyportal panel settings and I can compare them?
Title: Re: "recent topics" in SMF style
Post by: shane is my name on April 28, 2010, 02:45:21 AM
In the subject column, Is there a way to have it show who the thread was started by?
Title: Re: "recent topics" in SMF style
Post by: sangham.net on May 05, 2015, 09:54:23 AM
If useful an unprofessional modification, for everyone who likes such:

global $context, $modSettings, $txt, $settings;
$context['TPortal']['recentboxnum'] = '50';

if(isset($modSettings['recycle_board']))
$bb = $modSettings['recycle_board'];

$what = ssi_recentTopics($context['TPortal']['recentboxnum'], NULL, NULL, 'array');
$counter=1;
$cmax = count($what);

echo '
<div style="width: 100%; overflow: auto; height: 30ex;">';

foreach($what as $w)
{
echo '
<div class="smalltext"><b><a href="'.$w['href'].'">' . $w['short_subject'] . '<span style="color:black; font-weight: normal"> in </span></a></b></div> ';
echo '
<div class="smalltext"><span style="font-size:80%">', $w['board']['link'],
'</span></div>
<div class="smalltext">', $txt['by'], ' <span style="font-weight: 600"><i>', $w['poster']['link'], '</i></span></div>
<div class="smalltext">';
if(!$w['new'])
echo '<a href="'.$w['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '<span style="font-size:80%">['.$w['time'].']</span>
</div>';

if($counter != $cmax)
echo '<hr />';
$counter++;
}
echo '
</div>';


Changes (used the "original")
Attached a screenshot

modified
1- like the original
2- add 'Text'(text-weight normal)
3- add Board where posted (text-weight normal, size: 80%; note: the even smaller text in the pictur comes form another side)
4- 'by' (text-weight normal) Member (cursive)
5- (text-size: 80%)

Credits to: Moritz, generously done the "hard" stuff

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fsangham.net%2FSmileys%2Fsangham%2Fgift_sangham_sw.gif&hash=767334b6212d98936a6066e6d40b18685adc5e49)
Title: Re: "recent topics" in SMF style
Post by: MrCare on January 06, 2016, 06:14:40 AM
How to add the counting number of the topics before before topic icon?

like...

1   (https://www.tinyportal.net/Themes/AlphaCentauri/images/post/xx.gif)The title
2   (https://www.tinyportal.net/Themes/AlphaCentauri/images/post/xx.gif)The Post
3   (https://www.tinyportal.net/Themes/AlphaCentauri/images/post/xx.gif)Bla....