News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

PM Alert

Started by scottb, March 16, 2004, 04:31:51 PM

Previous topic - Next topic

scottb

Everytime you get a PM you get a little popup alert that tells you that you have a PM. Also make it something that could be switched on and off in the users profile.

pulpitfire

just go to index.template.php, and add the image of your choice in the code below.

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
echo ', ', $txt[152], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt[153] : $txt[471], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'];[\code]

scottb


finnhack

Quote from: pege on March 16, 2004, 04:39:43 PM
just go to index.template.php, and add the image of your choice in the code below.

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
echo ', ', $txt[152], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt[153] : $txt[471], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'];[\code]


Hi! I'm just looking for the same feature. I figured out it should be done as above, but something just tells me this isn't the complete code for doing that !? For a non-coder like me it would be nice to understand exactly were I should put the code for the image. Of course it would be possible to try it out but I prefer not to mess up my board too much. 

pulpitfire

#4
that is the text that shows you how many new messages you have.  you put the image wherever you want it to display in that text.  a likely location would be at the end. e.g., maybe something like:

$image = '<img src="http://www.yoursite.com/SMF/Themes/yourtheme/images/yourimage.gif" border="0" alt=""/>';
echo ', ', $txt[152], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt[153] : $txt[471], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'];
echo '.',' ', $context['user']['unread_messages'] > 0 ? $image : '';

finnhack

Thanks!

Now it seems much more understandable!

pulpitfire

welcome.  may have to tweak that to get it to work.  untested.

finnhack

Actually it worked nicely without any further tweaking!

Also tried to use the $settings['images_url'] to avoid hardcoded URLs in the template, but that did not have a happy end  ;)  But I'm really satisfied with the code posted above.

pulpitfire


paulo

That does not function at home. Here the error which is posted  :-[


Parse error: parse error in /home/.sites/132/site96/web/Test/Themes/default/index.template.php on line 34
Impossible de charger le modèle 'main_above'.

I made the following modifications:

// Only tell them about their messages if they can read their messages!
      if ($context['allow_pm'])
         echo ', ', $txt[152], ' <a href="', $scripturl, '?action=pm">', $context['user']['messages'], ' ', $context['user']['messages'] != 1 ? $txt[153] : $txt[471], '</a>', $txt['newmessages4'], ' ', $context['user']['unread_messages'], ' ', $context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1'];[\code]

which is the problem please ?

Thank you

pulpitfire

use some kind of editor, and see what's on line 34.  i used the code, as you showed it, defining all the variables, and it worked.  i think the error may be in some other part of your code.

paulo

Thank you pout your assistance.
Indeed, the error messages are: Undefined index..... , Undefined offset...

But I do not know how to define the variables. Could you give me the line of code already definite please? I am at all an expert.

Thank you

pulpitfire

well, i just supplied fake values for your variables.  do you want to copy the whole script, and post it here, between code brackets?  i'll try to debug it. 

paulo

#13
Now it's ok  :D

But on the other hand I thought that it was with a system of popup..  ::)

Advertisement: