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

Recent

Welcome to TinyPortal. Please login or sign up.

May 17, 2024, 10:44:19 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 59
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 65
  • Total: 65

"recent topics" in SMF style

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

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jacortina

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.

texasflats

DOH!! Your right.  :uglystupid2:

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

The code in my SSI.php:

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

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

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

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

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

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

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

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

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}


Thanks again!  :)

jacortina

Here you go. My mistake on the 128 character array entry name. Also changes link to start of thread:
global $scripturl, $txt;

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


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

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

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

            echo '
            </td>

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

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

        echo '
                        </table>';

mixman

Quote from: Bloc on August 17, 2005, 12:01:38 PM
- add board ID number like to the function if youw ant to narrow down the boards recent topics are taken from. change it to ssi_recentTopics('8', array('3','56') , 'array') where the numbers 3 and 56 are examples of board ID's.


Are those board #3 and #56? I tried several several different combinations of numbers to pull the 5 latest messages out of board 2. Can not get this to work...

jacortina

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

texasflats

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.

mixman

Quote from: J.A.Cortina on May 27, 2007, 04:57:49 PM
If you look up in this thread a couple of messages, http://www.tinyportal.net/index.php?topic=596.msg134627#msg134627 , you'll see a function that you can add to your SSI.php file (right before the "?>" at the end).

Then you'd call ssi_recentTopics_Include(5, array(2), 'array') .

Thanks! One action less untill launch :)

jacortina

Quote from: texasflats on May 27, 2007, 05:34:57 PM
Is it possible to make it pull the 128 chars from the original topic? The way it is, it pulls from the last reply.

Everything else is perfect, I can't thank you enough for all your help.

Not without a good amount of re-engineering of the SSI function or adding significant processing to  your block. The query it runs in the SSI function is specifically looking for the most recent activity. Building a link to the first message from the topic ID for a link is trivial (message #0 within a topic will point there). But the query pulls all the info for the most recent message posted in a topic. It would require adding the processing to first get the most recent posted to topics and then go back for each of those and read in the first message in that topic.

I'll take a look at it, but not sure when/if I can get something to you.

insanemustang

I really like this block.  I was wondering (hopefully it hasn't been posted and I missed it) how I could add the # of replies that have been made already?

I just need the specific coding and where to put it of the code below to make this happen, as I have already edited the look/function of my block

An example is here ---> http://www.bamanation.net

global $scripturl;
echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan=1>Topic</td><td>Most Recent Poster</td><td>Date</td></tr> ';
       $what=ssi_recentTopics('8', array('1','2','4','5','6','9','10','11','12','13','14','15','17','18','19','20','21','22','23',) , 'array');


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

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

                echo '
                                        </font></td>
                                        <td class="windowbg2" valign="middle" width="20%"><font size=1>
                                                ', $topic['poster']['link'], '
                                        </font></td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                echo '
                                                <span class="smalltext"><font size=1>
                                                        ', $topic['time'], '
                                                </font></span>


                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
echo'<br>';

IchBin

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.