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

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 09:42:14 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: 1
  • Guests: 105
  • Total: 106
  • tino

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

jacortina

Quote from: joh87swe on April 18, 2007, 07:12:39 PM
But I also want to use the same but only to show topics of a certain board. I have many boards and new boards are being added often so it would be wonderful if I only have to set the board id that I want to show topics from.
Thanks for help.

//Johan

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

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

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

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

Where '##' is the number (or comma separated list of numbers) of the board(s) you want the recent topics from.

javier

Currently this code show the


Topic title, author and date,

its possible make in this way?

Topic title, board, author and date,


grettings

jacortina


javier

#253
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

jacortina

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.

javier

 sorry, this its the code:

global $scripturl;

echo '

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


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

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

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

        echo '
                        </table>';



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

board title - topic title - last post date

excuse my english  :(
Best regards
Javier


baderick

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

jacortina

#257
Quote from: javier on May 09, 2007, 08:56:58 AM
Anyways i have not to use this code in obligatory way, all i trying to make its a code for show the recent topics list in this way:

board title - topic title - last post date

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

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);


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

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

To:
                                                ', $topic['board']['link'], ' - ', $topic['link'];

jacortina

Quote from: baderick on May 09, 2007, 01:10:54 PM
hi

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

thanks

baderick

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

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

global $db_prefix;

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


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

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

echo '<font color="' . $color_start . '">' . $row['realName'] . '</font>';

baderick

hi

thanks J.A.Cortina for your fast reply ill try that tonight when i get home from work :)