Advertisement:

Author Topic: New message feature  (Read 3838 times)

Offline diu

  • Semi-Newbie
  • *
  • Posts: 58
New message feature
« on: February 11, 2005, 10:52:35 AM »
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

Offline diu

  • Semi-Newbie
  • *
  • Posts: 58
Re: New message feature
« Reply #1 on: February 15, 2005, 10:08:48 AM »
what a success!!!

Offline Ben_S

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,725
  • xxx
Re: New message feature
« Reply #2 on: February 16, 2005, 07:32:24 AM »
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.

Offline diu

  • Semi-Newbie
  • *
  • Posts: 58
Re: New message feature
« Reply #3 on: February 16, 2005, 10:27:55 AM »
The code in the MessageIndex.template.php is:

Code: [Select]
// 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:

Code: [Select]
// 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:

Code: [Select]
// 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

Offline [Unknown]

  • SMF Friend
  • SMF Master
  • *
  • Posts: 36,102
  • Gender: Male
Re: New message feature
« Reply #4 on: March 11, 2005, 07:14:17 AM »
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]