TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 07:43:38 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 147
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 124
  • Total: 124

"recent topics" in SMF style

Started by Lesmond, August 17, 2005, 12:01:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

katoona

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?

jacortina

Quote from: katoona on May 10, 2007, 02:37:59 AM
I have set number of posts to 25 for one selected board, but if nobody make any post for few days, the recent posts dissapear until nobody is left.

Is there any workaround for this?

What code are you using (probably best to just include it here between [ code ] & [ /code ] (no spaces).

katoona

Quoteglobal $scripturl;

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


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

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

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

        echo '
                        </table>';

Sorry, her is the code I am using.

jacortina

OK, two points.

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

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

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

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

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

And this one later in the thread:
http://www.tinyportal.net/index.php?topic=1234.msg105913#msg105913

katoona

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.

jacortina

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.

katoona

#266
Quote from: J.A.Cortina on May 10, 2007, 03:09:32 AM
See this message:
http://www.tinyportal.net/index.php?topic=1234.msg105411#msg105411

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

You said: look for "(/a)", but can you be a little more spesific?

jacortina

#267
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.]

katoona

Lol, I am not that stupid, but where inside the file?

jacortina

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).