TinyPortal

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

Title: "recent topics" in SMF style
Post by: Bjørn on August 17, 2005, 05:01:38 AM
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.


Code: [Select]
       
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, 09:51:02 AM
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, 10:30:29 AM
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, 11:36:59 AM
Ah! ok thanks
Title: Re: "recent topics" in SMF style
Post by: Bjørn on August 17, 2005, 03: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, 04: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 17, 2005, 05:44:33 PM
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 17, 2005, 06:13:29 PM
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 17, 2005, 06:32:29 PM
You mean like the "recent posts" on the forum? (action=recent)
Title: Re: "recent topics" in SMF style
Post by: Ray on August 17, 2005, 08:45:16 PM
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, 07:37:01 AM
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, 09:38:23 AM
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, 03: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"><strong>Recent topics</strong></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'], '[/url]';

        echo '
                                        </td>

                                </tr>
                        </table>
                </td>
        </tr>
</table>

<a name="top">[/url]

<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" />[/url]';

                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;" />[/url]';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>
        <a name="lastPost">[/url]
                        <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, 06:08:07 AM
"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, 07:42:48 AM
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, 11:32:47 AM
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, 01: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, 06:21:12 AM
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, 09:51:51 AM
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, 04: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, 04: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, 01: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, 02: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, 03: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, 03:51:43 PM
 Any time m8.
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on August 26, 2005, 06:26:00 PM
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, 12: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, 03:18:14 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 28, 2005, 08:25:02 PM
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 28, 2005, 08:30:37 PM
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 28, 2005, 08:49:05 PM
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 28, 2005, 08:57:17 PM
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 28, 2005, 10:41:13 PM
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, 03: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, 05:40:07 AM
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, 07:49:43 AM
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, 08:37:01 AM
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, 04: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, 01: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, 01: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, 02:00:11 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, 02: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, 02: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, 02:34:36 PM
 ;D My pleasure
Title: Re: "recent topics" in SMF style
Post by: xtremecruiser on September 16, 2005, 03: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, 03: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, 03:37:33 PM
This better??
Title: Re: "recent topics" in SMF style
Post by: bloc on September 16, 2005, 04: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, 04: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, 04: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 23, 2006, 07:59:07 PM
Not "yet"....
Title: Re: "recent topics" in SMF style
Post by: ontap on March 01, 2006, 04:14:20 AM
when i use this recent topics block for the frontpage, error logs fills up with this error.

Code: [Select]
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, 10:42:00 AM
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" />[/url]';

Title: Re: "recent topics" in SMF style
Post by: ontap on March 03, 2006, 01:33:33 AM
You need to change $topic['newtime'] to $topic['time'] in the following section of the code.

Thanks.... here is the new code!

Code: [Select]
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, 01: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, 02:53:06 PM
Looks great, thanks for that!  8)
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 27, 2006, 07:53:30 PM
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
Code: [Select]
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 27, 2006, 07:55:54 PM
I got this from your link -  The page cannot be displayed.
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 27, 2006, 08:02:03 PM
arghh.. why not.. try it  www.ourmega.net
Title: Re: "recent topics" in SMF style
Post by: RoarinRow on March 27, 2006, 10:12:18 PM
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 27, 2006, 10:49:17 PM
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 27, 2006, 11:06:12 PM
Can not seem to get it to work also BlueSteel   :-\
Title: Re: "recent topics" in SMF style
Post by: IchBin on March 27, 2006, 11:57:28 PM
Works for me now...
Title: Re: "recent topics" in SMF style
Post by: Blue Steel on March 28, 2006, 12: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, 01: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, 02: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 28, 2006, 04:55:20 PM
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 28, 2006, 05:07:56 PM
ok here it is updated and re-organised and re-formatted

It should now only display the headings once

Code: [Select]
// "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 28, 2006, 09:14:08 PM
Works perfect and I am using it -- thank you
Title: Re: "recent topics" in SMF style
Post by: astpaul on April 03, 2006, 02: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, 07:39:04 AM
That's good stuff! Post away astpaul. :)
Title: Re: "recent topics" in SMF style
Post by: astpaul on April 03, 2006, 07:47:21 AM
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 :
Code: [Select]
// "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, 11:32:44 AM
Thank, that's so fine in some case  :)
Title: Re: "recent topics" in SMF style
Post by: technodragon73 on April 12, 2006, 10:43:02 AM
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, 11:54:06 AM
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?

Code: [Select]
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, 12: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 13, 2006, 07:06:09 PM
ahh i see.. thanks, i will try that out
Title: Re: "recent topics" in SMF style
Post by: jpark on April 15, 2006, 02: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, 03:49:24 AM
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:
Code: [Select]
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 19, 2006, 11:37:05 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, 05:07:52 AM
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, 07:52:09 AM
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, 04:21:35 AM
ok here it is updated and re-organised and re-formatted

It should now only display the headings once

Code: [Select]
// "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, 05:41:22 AM
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, 06:24:47 AM
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 April 30, 2006, 10:40:46 PM
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, 02: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, 08:01:41 AM
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, 09:03:51 AM
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, 11:34:27 AM
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, 12: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, 12:10:26 AM
ok here it is updated and re-organised and re-formatted

It should now only display the headings once

Code: [Select]
// "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 09, 2006, 06:49:51 PM
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, 02: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, 08:12:47 AM
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, 10:49:27 AM
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.

Code: [Select]
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, 07:07:50 AM
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, 07:59:02 AM
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, 08:21:47 AM
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, 04: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 11, 2006, 05:08:12 PM
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, 08:46:35 AM
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 13, 2006, 06:12:44 PM
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
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 17, 2006, 05:23:29 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 18, 2006, 05:40:56 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, 06:41:30 AM
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, 11:37:14 AM
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

Code: [Select]
// "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, 12: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, 12:49:22 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 May 31, 2006, 08:24:56 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

Code: [Select]
// "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, 06:41:55 AM
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 01, 2006, 08:50:36 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, 08:40:31 AM
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, 11:21:46 AM
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, 03: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, 09:17:19 AM
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, 10:43:40 AM
there is no "$topic['subject']" in script ???
Title: Re: "recent topics" in SMF style
Post by: jcortina on June 16, 2006, 11:15:13 AM
Sorry. $topic['link'] has the full length subject embedded in it. It is this line:

Code: [Select]

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


Try replacing that with:

Code: [Select]

    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 18, 2006, 10:01:00 PM
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 18, 2006, 11:31:40 PM
try adding:

Code: [Select]
<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 18, 2006, 11:34:52 PM
try adding:

Code: [Select]
<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, 12: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?

Code: [Select]
// "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:

Code: [Select]
// "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, 04: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, 04: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, 05:04:38 AM
position boxes?
Title: Re: "recent topics" in SMF style
Post by: akulion on July 24, 2006, 05:07:53 AM
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, 05:17:02 AM
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, 06:22:50 AM
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, 06:38:28 AM
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, 08:11:01 AM
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, 08:15:56 AM
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?

Code: [Select]
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, 12:52:11 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, 02:22:57 PM
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, 03:41:46 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).

Code: [Select]

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, 04: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

Code: [Select]
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, 04: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, 04:23:39 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, 09:58:32 AM
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.

Code: [Select]

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, 03: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 07, 2006, 05:19:04 PM
No problem (what was given was just the same format as used
in the Unread since Last).

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

Change to:
Code: [Select]
<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 07, 2006, 05:28:41 PM
No problem (what was given was just the same format as used
in the Unread since Last).

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

Change to:
Code: [Select]
<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 07, 2006, 10:37:30 PM
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 07, 2006, 10:49:40 PM
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, 12:00:22 PM
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).


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:
Code: [Select]
<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:
Code: [Select]
<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:
Code: [Select]
' , $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:
Code: [Select]
' , $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, 03:38:05 PM
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).


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:
Code: [Select]
<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:
Code: [Select]
<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:
Code: [Select]
' , $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:
Code: [Select]
' , $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 08, 2006, 06:52:26 PM
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 08, 2006, 07:17:34 PM
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 08, 2006, 08:43:35 PM
Just to confirm, the problem you experienced was with
Unread Replies, right?

If so, try -

Starting in Line 286:

Find:
Code: [Select]
<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:
Code: [Select]
<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 08, 2006, 09:36:47 PM
Just to confirm, the problem you experienced was with
Unread Replies, right?

If so, try -

Starting in Line 286:

Find:
Code: [Select]
<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:
Code: [Select]
<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, 07:14:38 AM
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, 04:12:29 PM
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:

Code: [Select]
$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
Code: [Select]
$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, 04:32:39 PM
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:

Code: [Select]
$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
Code: [Select]
$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, 01: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, 04:56:42 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:
Code: [Select]
ORDER BY t.ID_LAST_MSG DESC " . $limit_clause, __FILE__, __LINE__);

To:
Code: [Select]
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 13, 2006, 06:58:15 PM
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 13, 2006, 07:09:55 PM
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 13, 2006, 07:20:39 PM
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 13, 2006, 07:40:38 PM
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:
Code: [Select]
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:
Code: [Select]
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, 09:42:36 AM
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 26, 2006, 07:54:03 PM
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).

Code: [Select]
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 26, 2006, 08:00:04 PM
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 26, 2006, 10:00:40 PM
Wow, it gets better and better   :up:
Title: Re: "recent topics" in SMF style
Post by: akulion on September 27, 2006, 12: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, 07:14:14 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, 07:18:52 AM
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, 04: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 27, 2006, 05:07:45 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 27, 2006, 06:02:29 PM
Here you go. Specify board(s) to exclude. Not up for messing around trying to parse a passed in board list.

Code: [Select]
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 27, 2006, 06:22:56 PM
thanks - very good stuff :up: top of the pops :up:
Title: Re: "recent topics" in SMF style
Post by: daftdate on September 28, 2006, 12:11:12 AM
Thats wonderful thanx  :)
Title: Re: "recent topics" in SMF style
Post by: Svaha on September 28, 2006, 03: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, 08:46:24 AM
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, 09:21:06 AM
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, 11:32:09 AM
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, 12: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, 01:08:02 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, 01: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, 01: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 September 30, 2006, 05:34:04 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.

Code: [Select]
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 September 30, 2006, 10:22:43 PM
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 September 30, 2006, 10:44:56 PM
Does this block work in a side block without looking strange?
Title: Re: "recent topics" in SMF style
Post by: jacortina on September 30, 2006, 10:55:59 PM
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, 04: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, 04:39:55 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, 04: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, 04: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, 09:33:22 AM
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, 01: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, 02: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, 03: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, 03:49:48 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, 04: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 25, 2006, 07:42:25 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 25, 2006, 08:00:13 PM
And you said you were using code which called the SSI function.

$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 25, 2006, 10:18:46 PM
ok I am using this code -

Code: [Select]
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, 03:21:21 PM
ok I am using this code -

Code: [Select]
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, 03:34:38 PM
This piece seems to put out the 'new' image for topics which AREN'T new???

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

Does changing it to this help?
Code: [Select]
                // 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, 04:11:12 PM
This piece seems to put out the 'new' image for topics which AREN'T new???

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

Does changing it to this help?
Code: [Select]
                // 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 26, 2006, 09:52:08 PM
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, 06:13:23 AM
wow! that sounds like a whole new topic to me!
Title: Re: "recent topics" in SMF style
Post by: pvcblue on November 27, 2006, 08:09:07 AM
This piece seems to put out the 'new' image for topics which AREN'T new???

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

Does changing it to this help?
Code: [Select]
                // 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, 08:54:40 AM
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

Code: [Select]
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, 09:27:18 AM
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

Code: [Select]
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, 09:42:03 AM
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:

Code: [Select]
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, 11:11:21 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, 12: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, 01: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, 02: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, 02: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, 02: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, 02: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, 03: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 29, 2006, 05:51:33 PM
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 29, 2006, 08:20:28 PM
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, 11:40:40 AM
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, 12:10:29 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, 01: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, 01: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, 01: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, 01: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, 01: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, 02: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, 02: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, 02: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, 02: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, 03: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 24, 2007, 05:13:16 PM
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 24, 2007, 07:29:55 PM
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.

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.

Code: [Select]
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 24, 2007, 07:51:35 PM
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, 04: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, 11:15:09 AM
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, 11:57:43 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.

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.

Code: [Select]
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, 01: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, 11:04:11 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, 02: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, 03: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, 07:12:26 AM
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, 07:39:17 AM
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, 07:39:46 AM
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, 07:44:37 AM
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, 07:50:19 AM
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, 07:54:12 AM
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:

Code: [Select]
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):
Code: [Select]
'« 'to:
Code: [Select]
'« '
and the one:
Code: [Select]
' »'to:
Code: [Select]
' »'
Title: Re: "recent topics" in SMF style
Post by: jacortina on March 06, 2007, 08:07:18 AM
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, 08:12:02 AM
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, 08:12:37 AM
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:

Quote
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?

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, 08:15:37 AM
Quote
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).

That worked :)

Thank you J.A Cortina :)  :-*
Title: Re: "recent topics" in SMF style
Post by: mrbean17 on March 06, 2007, 10:21:21 AM
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, 10:25:01 AM
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, 11:05:43 AM
Ahhh, I'm smart. Thanks!
Title: Re: "recent topics" in SMF style
Post by: joh87swe on April 18, 2007, 12:12:39 PM
I use this code:
Code: [Select]
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, 07:35:51 AM
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:
Code: [Select]
       $what=ssi_recentTopics('5', NULL, 'array');
To:
Code: [Select]
       $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, 11:57:07 AM
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, 06:44:04 AM
What code are you using?
Title: Re: "recent topics" in SMF style
Post by: javier on May 01, 2007, 08:40:14 AM
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, 06:39:30 AM
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, 01:56:58 AM
 sorry, this its the code:

Code: [Select]
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, 06:10:54 AM
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, 08:13:30 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):

Code: [Select]
// 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:
Code: [Select]
                                                ', $topic['link'];
To:
Code: [Select]
                                                ', $topic['board']['link'], ' - ', $topic['link'];
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 09, 2007, 08:29:37 AM
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:

Code: [Select]
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:

Code: [Select]
$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, 08:36:55 AM
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 09, 2007, 07:37:59 PM
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 09, 2007, 07:42:54 PM
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 09, 2007, 07:50:14 PM
Quote
global $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" />[/url]';

                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 09, 2007, 08:09:32 PM
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:
Code: [Select]
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 09, 2007, 08:36:24 PM
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 09, 2007, 08:42:17 PM
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 09, 2007, 09:00:03 PM
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 09, 2007, 09:03:38 PM
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 09, 2007, 09:04:49 PM
Lol, I am not that stupid, but where inside the file?
Title: Re: "recent topics" in SMF style
Post by: jacortina on May 09, 2007, 09:07:12 PM
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 09, 2007, 09:36:11 PM
Again, thanks for your help. It works perfectly.
Title: Re: "recent topics" in SMF style
Post by: katoona on May 13, 2007, 02: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, 03: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, 03:50:06 PM
Quote
global $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 '[/url]
            </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, 04: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).

Code: [Select]
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, 04: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, 01:41:58 AM
thank you
Title: Re: "recent topics" in SMF style
Post by: texasflats on May 26, 2007, 09:59:43 AM
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:
Code: [Select]
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, 11:40:24 AM
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:
Code: [Select]
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, 01: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, 02: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, 08:05:21 AM
DOH!! Your right.  :uglystupid2:

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

The code in my SSI.php:

Code: [Select]
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, 08:20:37 AM
Here you go. My mistake on the 128 character array entry name. Also changes link to start of thread:
Code: [Select]
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, 09:47:06 AM
- 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, 09:57:49 AM
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, 10:34:57 AM
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, 10:58:07 AM
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, 11:25:55 AM
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, 04: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

Code: [Select]
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, 04: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 18, 2007, 05:24:37 PM
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 "?>"):
Code: [Select]
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:
Code: [Select]
       $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):
Code: [Select]
       $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 18, 2007, 08:57:41 PM
I will try this tomorrow.  Thanks for your help.

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 "?>"):
Code: [Select]
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:
Code: [Select]
       $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):
Code: [Select]
       $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, 11:47:50 AM
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, 12: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, 01:45:55 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 05, 2007, 07:06:06 PM
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 05, 2007, 07:16:38 PM
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, 09:01:36 AM
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, 11:31:59 AM
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, 12: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, 11:33:43 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.

Code: [Select]
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, 12:44:20 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 28, 2007, 10:19:35 PM
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:

Code: [Select]
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 28, 2007, 10:37:33 PM
That clause is:
Code: [Select]
        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:
Code: [Select]
//        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 28, 2007, 10:41:00 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 28, 2007, 11:02:34 PM

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 28, 2007, 11:11:49 PM
That clause is:
Code: [Select]
        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:
Code: [Select]
//        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, 07:14:14 AM
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:
Code: [Select]
      $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * max($list_count, 5));

and replace it with:
Code: [Select]
      $where_clause = '';

Code: [Select]
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 29, 2007, 09:48:27 PM
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, 08:10:29 AM
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:
Code: [Select]
foreach ($topics as $topic)
{

And do something like:
Code: [Select]
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, 04:09:26 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:
Code: [Select]
foreach ($topics as $topic)
{

And do something like:
Code: [Select]
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, 04:14:36 PM
It's the '50' in:
Code: [Select]
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, 04: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, 04: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, 04:50:38 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.
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.
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:

Code: [Select]
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'],
      &nbs