Log in

View Full Version : How do I display notifications total - New PM # ?


MikesSite
07-07-2011, 12:56 AM
In the notification menu where it says Your Notifications: #, is it possible to display the total notification # minus the PM total? So if you have 6 notifications but 2 are PM's the # would display 4. I ask because I plan on showing the PM total separate.

Thanks.

MikesSite
07-19-2011, 03:50 AM
Can somebody help me with this?

Thanks.

--------------- Added 1311135185 at 1311135185 ---------------

Is it possible to take $notifications_total and subtract $vbphrase[unread_x_nav_compiled] (I think thats the variable for PM total)??

MikesSite
10-20-2011, 12:51 AM
Still want to do this.

Lynn?!

kh99
10-20-2011, 01:12 AM
I think you can do what you want if you edit the header template and replace {vb:raw notifications_total} with

{vb:math {vb:raw notifications_total} - {vb:raw bbuserinfo.pmunread}}


Edit: ...except that's for vb4, as pointed out in the next post...

MikesSite
10-20-2011, 01:22 AM
For vb3?

kh99
10-20-2011, 01:44 AM
Oh...oops. Maybe $notifications_total - $bbuserinfo[pmunread] ?

Sorry, I'll have to look again, at the right code this time. :o

MikesSite
10-20-2011, 01:54 AM
Thanks! LMK if you come up with anything :)

kh99
10-20-2011, 02:08 AM
OK, I got confused with the vb4 stuff and forgot that you can't do math like that in a template. So you'd have to use a plugin and create a new variable. I think you can use hook location global_setup_complete and code like:

$notifications_not_pm = $notifications_total - $vbulletin->userinfo['pmunread'];


then use $notifications_not_pm (or whatever you want to call it) in the navbar template in place of $notifications_total (the first time it appears, not the one in the 'if' condition).

But that's for if you want the notifications to show up normally but the count to not include pms. If you want the notifications to disappear if there are only pm notifications (so that the count is 0), you should just change $notifications_total and reset $show['notifications'] if necessary, like:

$notifications_total -= $vbulletin->userinfo['pmunread'];
if ($notifications_total == 0)
$show['notifications'] = false;


and of course then you don't need to change the navbar template.

MikesSite
10-20-2011, 02:22 AM
Thanks. Unfortunately it doesn't seem to be working, it's outputting nothing. Possibly wrong hook location?

kh99
10-20-2011, 02:24 AM
Well, I did try both of those before posting and they seemed to work. Which one did you try?

MikesSite
10-20-2011, 02:32 AM
Ahh I'm sorry, it's my fault. It does work, but only if I use $notifications_not_pm in the navbar template. I need to use it in the header template.

kh99
10-20-2011, 02:38 AM
Oh, then you're right, that hook location won't work. Unfortunately there's no hook between $notifications_total being set and the header template being rendered. So you could edit global.php and insert the code.

Or you could cheat. The template processing doesn't let you put arbitrary php code in there, but you can sneak some stuff into a condition. So before you use the value in the header template you could put this:

<if condition="$notifications_not_pm = $notifications_total - $vbulletin->userinfo[pmunread]">
</if>


The if doesn't do anything, but the condition has a side-effect of setting that variable.

In either case you can disable the plugin.

MikesSite
10-21-2011, 05:27 PM
Thank you very much for the help kh99!! The 'cheat' works like a charm.