Advertisement:

Author Topic: PM Alert  (Read 6330 times)

Offline scottb

  • Jr. Member
  • **
  • Posts: 214
  • Gender: Male
  • Honor is Earned
    • Rupertgrint.org (official site for Rupert)
PM Alert
« on: March 16, 2004, 04:31:51 PM »
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.

Offline pulpitfire

  • Sophist Member
  • *****
  • Posts: 1,132
  • Gender: Male
  • This is what the php parser looks like.
    • Pulpitfire Devotionals
Re: PM Alert
« Reply #1 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.

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

Offline scottb

  • Jr. Member
  • **
  • Posts: 214
  • Gender: Male
  • Honor is Earned
    • Rupertgrint.org (official site for Rupert)
Re: PM Alert
« Reply #2 on: March 16, 2004, 09:29:36 PM »
Cool thanks

Offline finnhack

  • Semi-Newbie
  • *
  • Posts: 44
  • Gender: Male
Re: PM Alert
« Reply #3 on: March 22, 2004, 08:15:00 AM »
just go to index.template.php, and add the image of your choice in the code below.

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

Offline pulpitfire

  • Sophist Member
  • *****
  • Posts: 1,132
  • Gender: Male
  • This is what the php parser looks like.
    • Pulpitfire Devotionals
Re: PM Alert
« Reply #4 on: March 22, 2004, 08:26:02 AM »
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:
Code: [Select]
$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 : '';
« Last Edit: March 22, 2004, 08:33:28 AM by pege »

Offline finnhack

  • Semi-Newbie
  • *
  • Posts: 44
  • Gender: Male
Re: PM Alert
« Reply #5 on: March 22, 2004, 08:37:44 AM »
Thanks!

Now it seems much more understandable!

Offline pulpitfire

  • Sophist Member
  • *****
  • Posts: 1,132
  • Gender: Male
  • This is what the php parser looks like.
    • Pulpitfire Devotionals
Re: PM Alert
« Reply #6 on: March 22, 2004, 08:42:05 AM »
welcome.  may have to tweak that to get it to work.  untested.

Offline finnhack

  • Semi-Newbie
  • *
  • Posts: 44
  • Gender: Male
Re: PM Alert
« Reply #7 on: March 22, 2004, 10:56:02 AM »
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.

Offline pulpitfire

  • Sophist Member
  • *****
  • Posts: 1,132
  • Gender: Male
  • This is what the php parser looks like.
    • Pulpitfire Devotionals
Re: PM Alert
« Reply #8 on: March 22, 2004, 11:32:55 AM »
woo! \o/

Offline paulo

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
Re: PM Alert
« Reply #9 on: March 25, 2004, 10:58:02 AM »
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

Offline pulpitfire

  • Sophist Member
  • *****
  • Posts: 1,132
  • Gender: Male
  • This is what the php parser looks like.
    • Pulpitfire Devotionals
Re: PM Alert
« Reply #10 on: March 25, 2004, 01:44:12 PM »
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.

Offline paulo

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
Re: PM Alert
« Reply #11 on: March 25, 2004, 03:38:55 PM »
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

Offline pulpitfire

  • Sophist Member
  • *****
  • Posts: 1,132
  • Gender: Male
  • This is what the php parser looks like.
    • Pulpitfire Devotionals
Re: PM Alert
« Reply #12 on: March 25, 2004, 05:10:07 PM »
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. 

Offline paulo

  • Semi-Newbie
  • *
  • Posts: 47
  • Gender: Male
Re: PM Alert
« Reply #13 on: March 25, 2004, 06:02:56 PM »
Now it's ok  :D

But on the other hand I thought that it was with a system of popup..  ::)
« Last Edit: March 27, 2004, 12:29:38 PM by paulo »