News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

How can I mark messages unread for guests?

Started by Aaron10, September 17, 2014, 12:37:30 AM

Previous topic - Next topic

Aaron10

By default, all messages are marked as read/no new posts with off.gif

How can I have the opposite: all messages marked as unread with on.gif for guests?

Hj Ahmad Rasyid Hj Ismail

I guess you mean in BoardIndex? If more please let us know as we cannot read your mind. Basically, a check is made against a user when he logged in whether there are any new post or otherwise no. But if you want to show it as unread with on.gif for guest, IMO you need to modify BoardIndex.template.php. I am not sure if you can modify BoardIndex.php to do the same though.

This is the original code that you need to look for:
// If the board or children is new, show an indicator.
if ($board['new'] || $board['children_new'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'on', $board['new'] ? '' : '2', '.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />';
// Is it a redirection board?
elseif ($board['is_redirect'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'redirect.png" alt="*" title="*" />';
// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'off.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';


May be you can add a code just before off.gif code like this:
// If the board or children is new, show an indicator.
if ($board['new'] || $board['children_new'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'on', $board['new'] ? '' : '2', '.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />';
// Is it a redirection board?
elseif ($board['is_redirect'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'redirect.png" alt="*" title="*" />';
// Or the guest is actually viewing? Let's trick him
elseif ($context['user']['is_guest'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'on.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />';
// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'off.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';


Note: I haven't tested this code. ;)

Aaron10

Nope, that's exactly what I wanted and it works perfect. Also applied to messageindex for child boards. Thank you!

Hj Ahmad Rasyid Hj Ismail


Advertisement: