Audible alert upon new PM

Started by dbrown, October 11, 2006, 06:09:48 PM

Previous topic - Next topic

dbrown

Hey everyone. I developed a little hack that allows for an "audible alert" to be played when a user receives a new PM. I'm using Joomla 1.0.11, SMF RC3, and version 1.1.6 of Orstio's bridge, and it works great.

Basically, you just add the code to your Joomla template (You'll of course have to change it a bit to fit your template, and to match the audio file/directory you choose, but the core stuff is all there). I set mine up so it displays [ You Have: 35 messages, 0 are new ] in the pathway bar of my site. You can click it to go to your messages. I also added a little animated gif to my theme images folder (msg.gif) that displays next to "are new ]" when you have a new PM(s) as well as having the audible alert.

Here's the code:

Add this at the top of your Joomla template (I have it immeidately after the '_VALID_MOS' declaration.)
session_start();

Then, add this code wherever you need to:
<?php // If the user is logged in, display their messages in the header 
        
if ($context['user']['is_logged']) 
        { 
echo 
'[<span class="pathway2"> You Have: </span><a href="/index.php?option=com_smf&Itemid=137&action=pm" class="pathway2" title="Click To View Your Messages">' $context['user'
[
'messages'] ,' '$context['user']['messages'] != $txt[153] : $txt[471], ''$txt['newmessages4'], ' '$context['user']['unread_messages'], ' '$context['user']['unread_messages'] == ?  
$txt['newmessages0'] : $txt['newmessages1'], ' '$context['user']['unread_messages'] > '<img src="' $settings['images_url'] . '/msg.gif" border="0" />' ' '' </a>]&nbsp;&nbsp;', ($_SESSION['soundplayed'] !== true && $context['user']['unread_messages'] > )? "<bgsound src='/media/newmail.wav'>":""
        } 
       if(
$context['user']['unread_messages']>0
$_SESSION['soundplayed']=true;} ?>


I noticed after I made this that somebody released a MOD that does kind of the same thing. I like this better because with the session_start(); declaration, it will only play the sound once per session, rather than every time you refresh, or visit a different page. Enjoy!
Please do not PM me with support questions.  You will get better and faster responses by contacting someone who has a clue. Thank you.

blouogies20

Hey

Can you use this for smf 1.14 too?

Advertisement: