News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Newest Topics on Topics View

Started by Biology Forums, December 29, 2010, 02:59:12 PM

Previous topic - Next topic

Biology Forums

Is there a way of putting a "Newest Topics" section in topics view? Like a table on top that shows 4 of the newest posted topics, the amount of views and replies they've obtained, etc when a user is viewing a particular topic.

IchBin™

Adjust the number to be the board ID that you need. You can

if (isset($context['current_board']) && $context['current_board'] == 5)
{
    ssi_recentTopics(4);
}


Although ssi_recentTopics() doesn't show you replies and views by default, you can modify the output of the function.

IchBin™        TinyPortal


IchBin™

It produces the default layout of the SSI function which has a table in it.
IchBin™        TinyPortal

Biology Forums

Unfortunately it didn't work ??? But I can't imagine the code being so simple for such a drastic change. Don't you usually include the <table><tr><td> code for constructing a table with such information. In the index, the recent topics is in that format, how come this one isn't?

IchBin™

Because it's an SSI include. It allows you to custmize the look and layout of it. Didn't realize this was the SFM1.x board. So if you want the views and replies you'll have to add those to the query in the ssi_recentTopics() function inside of SSI.php. To find the name of those rows look at the smf_topics table in your database. Then you need to add them to the array in that function in the same manner that the others are added.

Then what you do is assign your call to a variable like this:
$ssitopics = ssi_recentTopics(4, 'array');

Then you can do a print_r() on that variable to see what is inside it.
echo '<pre>', print_r($ssitopics) ,'</pre>';

When you view the page you will see what is available for you to use in your table construction.

echo '
<table>';
    <tr>
        <th>Title</th>
        <th>Views</th>
        <th>Replies</th>
    </tr>';
foreach ($ssitopics as $topic) {
    echo '
    <tr>
        <td>', $topic['link'] ,'</td>
        <td>', $topic['numViews'] ,'</td>
        <td>', $topic['numReplies'] ,'</td>
    </tr>';
}
echo '
</table>';


You get stuck, post your code so we can see what you are doing.
IchBin™        TinyPortal

Biology Forums

Gosh I have no idea what you're talking about :-[ :-\

I've shown an example of what I'm thinking of doing.


IchBin™

Quote from: shuban on December 30, 2010, 11:35:00 PM
Gosh I have no idea what you're talking about :-[ :-\

Which part? Be specific. I'm not going to do this for you completely. I've practically already done that. I gave you the code above. All you have to do is add numReplies and numViews to the database query and array for the ssi function.

Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
IchBin™        TinyPortal


Advertisement: