View Full Version : PM RedAlert - show unread PMs on every page
Overgrow
03-01-2002, 10:00 PM
Disclaimer:
-No support is offered for this hack. If you PM or email for support, it will be joyfully ignored. When I have time, I will answer questions in this thread.
PM RedAlert
Problem: PM Popups are OK but not everyone likes them or uses them. Sometimes you'll cancel them and forget you have new ones to read.
Solution: If your site has a "Private Messages" link on every page, like mine, then an effective way to notify people that they have new PMs is to subtly change that link. PM Popup will still work if they have that activated.. and this is not like Chen's hack since that is only concerned with the index page. This hack is meant for site wide private message links that you would likely have in the header. (See attached screenshot)
Design Spec:
Alert users that they have new PMs on every page by subtly
changing a link style.
Steps for installation:
-add one field to table user 'unreadpm'
-edit two files 'private.php' 'private2.php'
-upload the two files
-edit header
Tested on: 2.2.1
Overgrow
03-02-2002, 04:54 PM
screenshot-- when a user has a new private message, the "Private Msgs" link will turn yellow and stay yellow until the user goes into Private Messaging. Of course it doesn't have to be "yellow" -- by checking the new variable $bbuserinfo[pmunread], you can do whatever you want.. make something animate, blink, turn fuscia, etc.
Psychdrone
03-02-2002, 04:58 PM
its nice, and thanks!
but I think I will stick with fireflys hack
Overgrow
03-02-2002, 05:00 PM
Two different goals with two different hacks.. Firefly's affects the index.php home page. Mine is meant if you have a "Private Messaging" link in your header on every page.
DjSap
03-02-2002, 05:55 PM
thanks, was planing on doing this for my board but now it dont have to, very nice
mvigod
03-02-2002, 06:41 PM
I wrote this hack for my board but didn't add another table to the database...think my way is a little more simple since it requires no DB change but the end result is the same.
In global.php
after:
// parse PHP include ##################
eval(gettemplate('phpinclude',0,0));
I put:
// Start Glow PM in Header Hack
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[user
id] AND messageread=0 AND folderid=0 $ignoreusers");
if ($unreadpm['messages']==0) {
$pmglow='PM';
} else {
$pmglow='<font color="red">New PM\'s</font>';
}
then in the header file just replace where the text that says PM is with the variable $pmglow and if the messages are unread it glows in red New PM's and if all messages have been read than it just reads "PM" in the regular color.
If you are using an image you can change the attribute for $pmglow to swap out the image or put an effect on it...whatever you like.
Overgrow
03-02-2002, 06:45 PM
Got a link to it? Or mind describing what you checked to see if there were unread PMs? I didn't use the pmpopup since it gets turned off once the javascript runs. If you don't use a new field (not a table) then you have to query the PM table each page load, which would be rough on a big site. I'm curious to your solution! thanks..
mvigod
03-02-2002, 06:52 PM
Overgrow,
Yes my solution does add that one extra query to each page. Guess it's a tradeoff depending on your site load versus wanting to add the extra DB field? It's fast query as userid is an indexed key in the pm table though.
Overgrow
03-02-2002, 06:52 PM
Ah yea, I avoided the extra query by including it in $bbuserinfo. For sites concerned about their database load, adding a new user field is preferable to adding a new query.. though your solution works just as well! Thanks.
And as Freddie pointed out to me somewhere else, I should remember to check what fields are indexed before determining what would be a slow query or not.
mvigod
03-02-2002, 07:01 PM
Just read through your hack and that extra query will be saved as you said. Just 2 different ways to skin a cat.
If a site is really loaded heavy I'd go Overgrow's route to save the one query but otherwise either works nicely. :)
Kumaro
03-03-2002, 01:05 AM
excellent hack! i'll test it later when i get time, but it sounds really good.
Kumaro
03-03-2002, 01:19 AM
Is it absolutly mandatory that we shut down our vb to run the query?
Overgrow
03-03-2002, 03:23 AM
>>Is it absolutly mandatory that we shut down our vb to run the query?
hahah no, that is your choice! It's advised but not mandatory.
Kumaro
03-03-2002, 12:18 PM
I get this error after running the query:
Error
SQL-query : [Edit]
ALTER TABLE 'user' ADD 'pmunread' SMALLINT(6) DEFAULT "0" NOT NULL
MySQL said:
You have an error in your SQL syntax near ''user' ADD 'pmunread' SMALLINT(6) DEFAULT "0" NOT NULL' at line 1
Overgrow
03-03-2002, 02:27 PM
Sorry, extra quotes got in there somehow. This is the correct query:
ALTER TABLE user ADD pmunread SMALLINT(6) DEFAULT "0" NOT NULL;
That works and I've updated the text file. Thanks.
this is a great hack.. :) i think a good mod would be to have it blink in a little table, right beside the nav bar. alot more visible. just a suggestion.
regards,
nakkid.
Overgrow
03-03-2002, 03:12 PM
Thanks man. Nice new logo up top there.. If you want to make your site blink, more power to ya ;) Most people use image buttons and not text links like I do, so substituting a GIF with an animated new PM gif would be the way to go.
excellent point.. and thanks for the logo thing.. ;)
Kumaro
03-03-2002, 09:42 PM
this works great! thanks overgrow!
streamzone
03-03-2002, 11:58 PM
i like the looks of this. i did everythin up til this point here:
"4) Change your site-wide Private Messaging link. Mine is located in my PHP
parsed header file and I do something like this:
if ($bbuserinfo[userid] > 0 and $bbuserinfo[pmunread]==1)
$pmstyle=" style=\"color:#ffdc00;\"";"
I am terribly n00b on that. I honestly have no clue what that means or where to look for it.
<shame>
haha
trainer
03-20-2002, 10:24 PM
could someone explain how to use a image? i can not figure it out and would really like to add this to my site
right now i have a image in the header that points to the members PM. how would i change this to another image (a flashing image) when that user has a new PM
this is a great hack just stuck on the end part
thanks
trainer
03-22-2002, 02:07 AM
Originally posted by streamzone
i like the looks of this. i did everythin up til this point here:
"4) Change your site-wide Private Messaging link. Mine is located in my PHP
parsed header file and I do something like this:
if ($bbuserinfo[userid] > 0 and $bbuserinfo[pmunread]==1)
$pmstyle=" style=\"color:#ffdc00;\"";"
I am terribly n00b on that. I honestly have no clue what that means or where to look for it.
<shame>
haha
i am in the same stop you are. i have everything upto that point figured out and done but no luck understanding the last part
already have a PM image and a flashing PM image all ready to go! maybe some of the more experience guys can help us out.
trainer
03-22-2002, 07:20 PM
bump to the top for some answers
thanks
trainer
03-23-2002, 03:27 PM
went with just the straight text to make sure this hack was working correctly before trying to change it over to a gif.
the text highlights only on the first page loaded when there is a new PM. hit i hit another page then the text is no longer highlighted even when i still have unread PM's
any suggestions or ideas?
trainer
03-25-2002, 08:59 PM
anyone?
WallStreat
04-05-2002, 02:25 PM
To Trainer:
This is how u add the blinking imgae:
if ($bbuserinfo[userid] > 0 and $bbuserinfo[pmunread]==1)
{
$pm="<div><p><A HREF=\"private.php?s=$session[sessionhash]\"><img src=\"https://vborg.vbsupport.ru/green/blinkingpm.gif\" border=0></A></p></div>";
}
trainer
04-05-2002, 02:40 PM
Originally posted by WallStreat
To Trainer:
This is how u add the blinking imgae:
if ($bbuserinfo[userid] > 0 and $bbuserinfo[pmunread]==1)
{
$pm="<div><p><A HREF=\"private.php?s=$session[sessionhash]\"><img src=\"https://vborg.vbsupport.ru/green/blinkingpm.gif\" border=0></A></p></div>";
}
ok i put that code in my phpinclude template
how do i call it in the header?
using pm-button.gif as the non-flashing button
using pm-button_ani.gif as the flashing button
350Chevy
11-19-2002, 08:07 AM
Still no straight answer..
Where is this supposed to go!??
4) Change your site-wide Private Messaging link. Mine is located in my PHP
parsed header file and I do something like this:
if ($bbuserinfo[userid] > 0 and $bbuserinfo[pmunread]==1)
$pmstyle=" style=\"color:#ffdc00;\"";"
350Chevy
11-20-2002, 12:21 AM
Anyone?
I don't understand how this can be called a final release when there are no instructions on where to place the last peice of code.
I'm using an animated .gif. Currently I just have a simple edited header template that shows a button and link to PM's. I've tried to place
if ($bbuserinfo[userid] > 0 and $bbuserinfo[pmunread]==1)
$pmstyle="{ imagesfolder }/pmgif1.gif"
{ else }
$pmstyle="{ imagesfolder }/pmgif.gif"
<a href="private.php?s=$session[sessionhash]"><img src="$pmstyle" alt="Here you can view your private messages" border="0"></a>
(without the spaces of course...)
Into the header but as you can tell it will not work. Any help on this half released mod would be appreciative.
Aaron1
11-20-2002, 02:07 PM
Originally posted by mvigod
I wrote this hack for my board but didn't add another table to the database...think my way is a little more simple since it requires no DB change but the end result is the same.
In global.php
after:
// parse PHP include ##################
eval(gettemplate('phpinclude',0,0));
I put:
// Start Glow PM in Header Hack
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[user
id] AND messageread=0 AND folderid=0 $ignoreusers");
if ($unreadpm['messages']==0) {
$pmglow='PM';
} else {
$pmglow='<font color="red">New PM\'s</font>';
}
then in the header file just replace where the text that says PM is with the variable $pmglow and if the messages are unread it glows in red New PM's and if all messages have been read than it just reads "PM" in the regular color.
If you are using an image you can change the attribute for $pmglow to swap out the image or put an effect on it...whatever you like.
Your hack works well if you're a registered user on the forum.
But when you're not logged in (guest user), the status will show, that you have unread private messages! Weird :-)
I don't think thats ok, do you think you can solve that matter/problem?
Thanks in advance...
350Chevy
11-24-2002, 01:32 AM
Originally posted by 350Chevy
[B]Anyone?
Due to the lack of help I found a much easier and better explained mod that works flawlessly at:
https://vborg.vbsupport.ru/showthread.php?s=&threadid=37427&perpage=15&display=&pagenumber=1
Thanks for sharing though.
esoin
01-30-2003, 06:38 PM
will this hack work with 2.2.9? I can't find the FIRST CODE in the FIRST STEP in the global.php
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.