Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: marten on January 12, 2006, 08:40:11 PM

Title: Hack: new message flashing icon
Post by: marten on January 12, 2006, 08:40:11 PM
A little useful hack for the new Core Theme (NDT).

When you get a message you'll se a fashing icon next to the message button in the top menu.
Without this flashing icon it is hard to notice when u get a message, at least for me  ;)


Find index.template.php in Themes/default
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>

Replace with:
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]&nbsp;&nbsp;<img src="' . $settings['images_url'] . '/newpm.gif" border="0" />' : '' , '</a>


You also need the flashing image newpm.gif and upload that to Themes/default/images.

I put the one I use here, so just right click on it and save it to your computer.

(http://www.hellasob.com/w3timages/newpm.gif)  

http://www.hellasob.com/w3timages/newpm.gif
Title: Re: Hack: new message flashing icon
Post by: Simplemachines Cowboy on January 12, 2006, 09:12:37 PM
Absolutely way cool.

Thanks for doing this!
Title: Re: Hack: new message flashing icon
Post by: 1MileCrash on January 12, 2006, 09:18:59 PM
who made that icon? it looks very familiar...
Title: Re: Hack: new message flashing icon
Post by: Bigguy on January 12, 2006, 09:40:57 PM
we could use any flashing icon though right ? and yep it does look familiar, just dont know from where.
Title: Re: Hack: new message flashing icon
Post by: snork13 on January 12, 2006, 09:45:11 PM
Quote from: Bigguy on January 12, 2006, 09:40:57 PM
we could use any flashing icon though right ? and yep it does look familiar, just dont know from where.

yes, and it's already in tip and tricks...which is why it looks familiar..i use this one -->
Title: Re: Hack: new message flashing icon
Post by: marten on January 12, 2006, 09:48:10 PM
Quote from: Bigguy on January 12, 2006, 09:40:57 PM
we could use any flashing icon though right ? and yep it does look familiar, just dont know from where.
Yes you can use any icon you want, just remember to name it right  or rename the image in the code.

Well I have seen that icon in many places too, I just used Google and found some and did choose this one  :D
Title: Re: Hack: new message flashing icon
Post by: marten on January 12, 2006, 09:53:19 PM
Quote from: snork13 on January 12, 2006, 09:45:11 PM
Quote from: Bigguy on January 12, 2006, 09:40:57 PM
we could use any flashing icon though right ? and yep it does look familiar, just dont know from where.

yes, and it's already in tip and tricks...which is why it looks familiar..i use this one -->
It is in tip and trick?? You mean a hack for RC2 NDT ..?  Anyway  your icon looks so much nicer so I think I will use that one instead :)
Title: Re: Hack: new message flashing icon
Post by: Bigguy on January 12, 2006, 10:22:55 PM
I just put it on my board and it works like a charm. Thanks for this. :)
Title: Re: Hack: new message flashing icon
Post by: Dexy on January 13, 2006, 10:53:12 AM
I cant find
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>

in index.template.php

p.s. i am using macvision theme, is that problem?
Title: Re: Hack: new message flashing icon
Post by: psychophat on January 14, 2006, 05:24:50 PM
Can this be used also in the default SMF theme?
Title: Re: Hack: new message flashing icon
Post by: Bigguy on January 14, 2006, 05:28:47 PM
I used this on the default smf 1.1 RC2 theme and it works fine.
Title: Re: Hack: new message flashing icon
Post by: psychophat on January 14, 2006, 05:42:46 PM
Way cool I'm going to put it right away.
Title: Re: Hack: new message flashing icon
Post by: Bigguy on January 14, 2006, 05:52:52 PM
Theres also one around that plays a sound file "You`ve got mail" when you recieve a PM.
Title: Re: Hack: new message flashing icon
Post by: marten on January 14, 2006, 08:56:40 PM
Hello again.

It is rather simple if you also want the sound "You`ve got mail" also.
In the code here i have used the IE tag "bgsound", but bgsound is a proprietary IE tag it isn't W3C standard so it won't work in Firefox, it should work in Opera though.

To allow playback of bgsound or embedded tags in Firefox you need an extension/plugin.

look for the same code as above. ( Still this is only for the New Default Theme for 1.1 RC2 )

Find index.template.php in Themes/default
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>


Replace with:
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]&nbsp;&nbsp;<img src="' . $settings['images_url'] . '/newpm.gif" border="0"><bgsound src="' . $settings['images_url'] . '/mail.wav" border="0">' : '' , '</a>


I have used a WAV file in this example called  "mail.wav"  so don't forget to change the name to what u want.

Upload the mail.wav file to Themes/default/images

You can find "You`ve got mail" wav files at this site (  I use - Mail03.wav Typical, "You've got mail". )

http://www.ilovewavs.com/Events/GotMail/GotMail.htm (http://www.ilovewavs.com/Events/GotMail/GotMail.htm)



Title: Re: Hack: new message flashing icon
Post by: Bigguy on January 14, 2006, 09:20:00 PM
Psyclones has made a hack to almost the same as this, he also has one I do believe for playing swf instead of wav. Which means of course no plugin is necessary, thats always nice.
Title: Re: Hack: new message flashing icon
Post by: Dexy on January 15, 2006, 05:26:37 AM
I have SMF 1.0.5. is there any hack for this version?
tnx
Title: Re: Hack: new message flashing icon
Post by: marten on January 15, 2006, 06:34:24 AM
Quote from: Dexy on January 15, 2006, 05:26:37 AM
I have SMF 1.0.5. is there any hack for this version?
tnx

Yes it is Tips and Tricks, at least I think it is for 1.05 , as someone pointed out here above ( I have never used that version myself ).
http://www.simplemachines.org/community/index.php?topic=9017.0 (http://www.simplemachines.org/community/index.php?topic=9017.0)
Title: Re: Hack: new message flashing icon
Post by: marten on January 15, 2006, 07:00:13 AM
Quote from: Bigguy on January 14, 2006, 09:20:00 PM
Psyclones has made a hack to almost the same as this, he also has one I do believe for playing swf instead of wav. Which means of course no plugin is necessary, thats always nice.

If so and it works with swf it will be a better choice ( havn't checked the hack ) , I don't use sound on my own board, only the animated icon, and u are right IF users have SWF turned on. Many users have that function turned OFF in their browers, because so many don't like SWF.. so my little hack work with most browsers except for Firefox witout a downloadable addon/extension to support BGSOUND. I dont't like sites either threre u visit websites with background musik, often MIDI files, and u can't turn it off BUT there are so many sites out there that uses bgsound and u can't hear the music then.

https://addons.mozilla.org/extensions/moreinfo.php?id=146 (https://addons.mozilla.org/extensions/moreinfo.php?id=146)
Title: Re: Hack: new message flashing icon
Post by: FBI on January 30, 2006, 01:27:11 PM
I have bad idea. For guest visitor, playing the applause.wav.
Visitor who didnt register/login into forum, they will heard applaus sound :)
Its weird and feel bad (I think). But useful, you can push visitor to register into your forum.

Here the code

Go find the code inside /Themes/index.template.php
// Otherwise they're a guest - so politely ask them to register or login.
else
{
echo '
', $txt['welcome_guest'], '<br />
', $context['current_time'], '<br />';
        }


And add this code
Quoteecho '<bgsound src="http://www.yoursite.com/Applause.wav" border="0">';

And the full code are:
// Otherwise they're a guest - so politely ask them to register or login.
else
{
echo '
', $txt['welcome_guest'], '<br />
', $context['current_time'], '<br />';
              echo '<bgsound src="http://www.yoursite.com/Applause.wav" border="0">';
}


Get the wav here (http://www.ilovewavs.com/Effects/People/People.htm)
Get the sample result at my forum here (http://www.forumbebas.com/forum)

Tested on IE and Opera

Its Bad Idea or Good idea? ;D

PS: You can record your own voice that speak "Welcome to my forum, please login.. bla.. bla.. bla"
Title: Re: Hack: new message flashing icon
Post by: Xerxes on February 19, 2006, 09:19:31 AM
I just added this to 1.1 RC2 and it works great. It's the simple things that make communication more effective. Thanks.
Title: Re: Hack: new message flashing icon
Post by: copfirearms on February 24, 2006, 05:57:01 PM
Quote from: marten on January 12, 2006, 08:40:11 PM
A little useful hack for the new Core Theme (NDT).

When you get a message you'll se a fashing icon next to the message button in the top menu.
Without this flashing icon it is hard to notice when u get a message, at least for me  ;)


Find index.template.php in Themes/default
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>

Replace with:
// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]&nbsp;&nbsp;<img src="' . $settings['images_url'] . '/newpm.gif" border="0" />' : '' , '</a>


You also need the flashing image newpm.gif and upload that to Themes/default/images.

I put the one I use here, so just right click on it and save it to your computer.

(http://www.hellasob.com/w3timages/newpm.gif)  

http://www.hellasob.com/w3timages/newpm.gif


Ok, I inserted  your code, heres what it looks like...

(http://img515.imageshack.us/img515/2249/image11wm.gif) (http://imageshack.us)

Any way to move the flashing icon to the center??
Or move it from where it's at?

If I could make it look like this, it woulld be great...
Thanks

(http://img502.imageshack.us/img502/65/image27tg.gif) (http://imageshack.us)
Title: Re: Hack: new message flashing icon
Post by: snork13 on February 24, 2006, 06:02:31 PM
i pacakged this up for 1.1rc2, check it out here (http://mods.simplemachines.org/index.php?mod=260)

Title: Re: Hack: new message flashing icon
Post by: copfirearms on February 24, 2006, 06:29:51 PM
Quote from: snork13 on February 24, 2006, 06:02:31 PM
i pacakged this up for 1.1rc2, check it out here (http://mods.simplemachines.org/index.php?mod=260)



I feel stupid for not seeing that !!!
Installed perfectly..
Thank You
Title: Re: Hack: new message flashing icon
Post by: h4ni on December 22, 2006, 04:25:32 AM
How i can apply this tips in my the musiconia

code:
Quote
   // Go to PM center... [pm]
   if ($context['user']['is_logged'] && $context['allow_pm'])
   {
      echo ((isset($current_action) && $curent_action == 'pm') || $context['browser']['is_ie4']) ? '' : '' , '
               <a href="', $scripturl, '?action=pm">Messages Privés</a>: ', $context['user']['unread_messages'], ' Non Lus, ', $context['user']['messages'], ' Total.<br />';
   }

thank you
Title: Re: Hack: new message flashing icon
Post by: AtelierGal on December 22, 2006, 08:59:55 AM
I'm using 1.1.1 and it's not possible to install

I got this:
QuoteThe package you are trying to download or install is either corrupt or not compatible with this version of SMF.
Title: Re: Hack: new message flashing icon
Post by: vbgamer45 on December 22, 2006, 03:21:31 PM
Contact Snork to update the mod or

Should work fine on 1.1.1 if you trick the package manager url.

Go to the package manager in your forum
In the address bar add
;version_emulate=1.1

To the url and hit enter to load the page or press go and you should be able to install the mod.
Title: Re: Hack: new message flashing icon
Post by: FBI on December 24, 2006, 01:34:54 AM
I didn use Mod Package Manager. Just using this code, work perfectly on any SMF version and themes (currently Simplicity). Just put it on index.template.php in any side (need html knowledge). Show Welcome screen and Flashing PM (if any).. :)

Windows Pop Up will show, if you have message. And at IE, directly opening New Windows.

// Show Flashy icon if user has new messages and it not a guest
if (!$context['user']['is_guest'] && $context['user']['unread_messages'])
echo '
<a href="' . $scripturl . '?action=pm"><img src="http://forumbebas.net/Themes/newpm.gif" border="0" /> klik here disini..</a> ' . $context['menu_separator'] . '';


}
else
echo $txt['welcome_guest'];
Title: Re: Hack: new message flashing icon
Post by: h4ni on December 24, 2006, 05:04:00 AM
i musiconia theme you put this code

Quote// Go to PM center... [pm]
   if ($context['user']['is_logged'] && $context['allow_pm'])
   {
      echo ((isset($current_action) && $curent_action == 'pm') || $context['browser']['is_ie4']) ? '' : '' , '
         |&nbsp;<span class="smalltext"><a href="', $scripturl, '?action=pm">Messages Privés</a>: '. $context['user']['unread_messages'] . '', $context['user']['unread_messages'] > 0 ? '<img src="' . $settings['images_url'] . '/icons/pmnotify.gif" width="12" height="12" align="absmiddle" />' : '' , '&nbsp;Non Lus, ', $context['user']['messages'], ' Total.</span><br />';
   }

work fine
Title: Re: Hack: new message flashing icon
Post by: qubbah on February 21, 2007, 11:31:37 AM
how about custom theme...

like

// Go to PM center... [pm]
   if ($context['user']['is_logged'] && $context['allow_pm'])      
   echo'
            <td align="center" class="menubg' , $current_action == 'pm' ? '2' : '' , '">
               <a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>   
Title: Re: Hack: new message flashing icon
Post by: fatihsinan on February 21, 2007, 02:38:39 PM
thank you for hack
Title: Re: Hack: new message flashing icon
Post by: ManilaGurL on July 04, 2007, 09:44:21 PM
Will this work with the latest version?
Title: Re: Hack: new message flashing icon
Post by: TrueSatan on July 05, 2007, 04:25:46 AM
Yes...see Snork's official package of it in the mods pages http://custom.simplemachines.org/mods/index.php?mod=260 (http://custom.simplemachines.org/mods/index.php?mod=260)
Title: Re: Hack: new message flashing icon
Post by: saosangmo on July 31, 2007, 01:27:08 PM
I wonder if I can do the same thing with http://www.openhosting.co.uk/articles/webdev/6004/
Meaning when my user is inactive and someone send him a message, a warning will display to tell him.
Title: Re: Hack: new message flashing icon
Post by: kpel on August 21, 2007, 09:33:47 PM
Thanks Marten!

This is the ONLY mod I've been able to get to work so far and I love it. (thanks for a moment of accomplishment!)
Title: Re: Hack: new message flashing icon
Post by: Fallen Angel on November 16, 2007, 03:38:32 PM
In Dilber MC

Find index.template.php in Themes/dilbermc


// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo'
<td align="center" class="menubg' , $current_action == 'pm' ? '2' : '' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>


Change with;


// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo'
<td align="center" class="menubg' , $current_action == 'pm' ? '2' : '' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]&nbsp;<img src="' . $settings['images_url'] . '/msg.gif" border="0">' : '' , '</a>


Works for me!  ;D
Title: Re: Hack: new message flashing icon
Post by: spaarks on December 09, 2007, 05:14:25 PM
Marten an excellent mod. I'm very much a newcomer to php so excuse me for asking a simple question. Do I have to replace the whole code section or can I just change the last bit to      . '</strong>]&nbsp;&nbsp;<img src="' . $settings['images_url'] . '/newpm.gif" border="0" />' : '' , '</a>

thanks
Title: Re: Hack: new message flashing icon
Post by: vbgamer45 on December 09, 2007, 09:07:45 PM
Just change the last bit.
Title: Re: Hack: new message flashing icon
Post by: spaarks on December 09, 2007, 09:13:13 PM
Thanks
Title: Re: Hack: new message flashing icon
Post by: De4thPr00f on December 10, 2007, 12:01:03 AM
@copfirearms:
to place the icon at the center you need to insert it in a div. i havn't look at the code, but you should have a part that gets the image. The changes you would do are:
<div id="msgicon" align="center" border=0> //before the icon thing
</div> //after the icon thing.
Title: Re: Hack: new message flashing icon
Post by: spaarks on December 18, 2007, 02:32:55 PM
How can I put the flashing mail icon in other themes such as "Cool Mint and Blue"
Title: Re: Hack: new message flashing icon
Post by: kizer on February 04, 2008, 01:32:03 PM
I love this mod. I often hit the front page and click the box saying cancel on the PM and now I simply can not forget that I did that with that annoying flashing images.

Thanks. ;)
Title: Re: Hack: new message flashing icon
Post by: Jed C on July 09, 2008, 06:49:08 PM
i installed this mod a while ago and had no probs until now  ::)
i had my flashy icon flashing in the message tab (cannot remember how i did that)
but i have just centred my tabs and it is now flashing to the left again
i read reply to copfirearms but my code is not the same
any ideas  ???

Quoteglobal $context, $settings, $options, $scripturl, $txt;  // Show Flashy icon if user has new messages and it not a guest
if (!$context['user']['is_guest'] && $context['user']['unread_messages'])
                             echo '
<a href="' . $scripturl . '?action=im"><img src="' . $settings['images_url'] . '/newpm.gif" border="0" />(' . $context['user']['unread_messages'] . ')</a> ' . $context['menu_separator'] . '';
Title: Re: Hack: new message flashing icon
Post by: TomW on January 24, 2010, 08:06:48 PM
Yes, I know that this is an OLD topic, but I would like to use this method for my 2.0 RC2 upgrade.  What changes are required ?
Title: Re: Hack: new message flashing icon
Post by: TomW on February 09, 2010, 10:55:56 AM
Quote from: TomW on January 24, 2010, 08:06:48 PM
Yes, I know that this is an OLD topic, but I would like to use this method for my 2.0 RC2 upgrade.  What changes are required ?

Bueller ?
Title: Re: Hack: new message flashing icon
Post by: waruna on February 11, 2010, 09:22:38 AM
Guys, what code for SMF2.0 RC2? Thanks in advance :D
Title: Re: Hack: new message flashing icon
Post by: balti27 on May 29, 2010, 11:23:32 AM
OK i made something and it worked for me.

As follows:

Copy the msg.gif file in the Main directory of your webspace.

Open Forum/Sources/Subs.php

Search for:
$context['menu_buttons'][$current_action]['active_button'] = true;

if (!$user_info['is_guest'] && $context['user']['unread_messages'] > 0 && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}
}


And Change it to:
$context['menu_buttons'][$current_action]['active_button'] = true;

if (!$user_info['is_guest'] && $context['user']['unread_messages'] > 0 && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]&nbsp;&nbsp;<img src="' . $settings['images_url'] . '/msg.gif" border="0" />';
}
}
Title: Re: Hack: new message flashing icon
Post by: balti27 on May 30, 2010, 09:39:56 AM
I hope thise mod is going to be updatet for smf rc3  ;D