News:

Wondering if this will always be free?  See why free is better.

Main Menu

New message feature

Started by diu, February 11, 2005, 10:52:35 AM

Previous topic - Next topic

diu

I'm looking for a mod or php code in other to see de new message image over Next, Before links when you are reading a message. I saw them in a old forum but i don't know how to make it.

I thinks they were very usefull

diu

pd: excuse my english

diu


Ben_S

It's hard to do, the next and previous links work out what the next topic is when it is clicked, so untill it is actually clicked, it does not know what the next topic is.
Liverpool FC Forum with 14 million+ posts.

diu

The code in the MessageIndex.template.php is:

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


And in the Display.template.php there is the next code in order to show the links:

// Show the previous/next links.
echo '
<td valign="bottom" align="right" class="smalltext">
<span class="nav">', $context['previous_next'], '</span>
</td>
</tr>


And in the botton the code is similar. I know there was a code which show new.gif here. And finally in the Display.php appear:

// Find the previous or next topic.  Make a fuss if there are no more.
if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next'))
{
// Just prepare some variables that are used in the query.
$gt_lt = $_REQUEST['prev_next'] == 'prev' ? '>' : '<';
$order = $_REQUEST['prev_next'] == 'prev' ? '' : ' DESC';

$request = db_query("
SELECT t2.ID_TOPIC
FROM {$db_prefix}topics AS t, {$db_prefix}topics AS t2, {$db_prefix}messages AS m, {$db_prefix}messages AS m2
WHERE m.ID_MSG = t.ID_LAST_MSG
AND t.ID_TOPIC = $topic" . (empty($modSettings['enableStickyTopics']) ? "
AND m2.posterTime $gt_lt m.posterTime" : "
AND ((m2.posterTime $gt_lt m.posterTime AND t2.isSticky $gt_lt= t.isSticky) OR t2.isSticky $gt_lt t.isSticky)") . "
AND t2.ID_LAST_MSG = m2.ID_MSG
AND t2.ID_BOARD = $board
ORDER BY" . (empty($modSettings['enableStickyTopics']) ? '' : " t2.isSticky$order,") . " m2.posterTime$order
LIMIT 1", __FILE__, __LINE__);

// No more left.
if (mysql_num_rows($request) == 0)
fatal_lang_error('previous_next_end', false);

// Now you can be sure $topic is the ID_TOPIC to view.
list ($topic) = mysql_fetch_row($request);
mysql_free_result($request);

$context['current_topic'] = $topic;

// Go to the newest message on this topic.
$_REQUEST['start'] = 'new';
}


My knowledge finish here... I can't modify it in order to show new.gif un next/previous links...

diu

[Unknown]

This is possible, but keep in mind that the query you quoted is one of the least efficient queries in SMF.  Running it for every topic would, in my opinion, be a bad thing.

-[Unknown]

Advertisement: