PDA

View Full Version : Using VBulletin 3.7.x notifications engine


FractalizeR
30 May 2008, 12:26
Everyone saw a nice drop-down list with all notifications you have at the top-right corner of every page. Let's look, how to add our own notifications to this list. It is very easy!

1. Create a GLOBAL phrase, that will be displayed as a text for your notification. Let's consider it's name to be MyNotificationName.
2. Create plugin for hook notifications_list with the following code:

if($MyNotificationNeedsToBeShown) {
$notifications['MyNotificationName'] = array(
'phrase' => $vbphrase['MyNotificationName'],
'link' => 'mylinkpage.php',
'order' => 100
);
$vbulletin->userinfo['MyNotificationName'] = $MyNotificationCount;
}
MyNotificationName - is just a string, a unique name of your notification.
$MyNotificationNeedsToBeShown - you can insert here any condition, that evaluates to true, then your notification needs to be shown
mylinkpage.php - is the name of the page, user will be redirected to, when he clicks your notification in menu. Page name should be relative to VB root or absolute (http://...)
$MyNotificationCount - a number, that will be shown near your notification. This number will be added to a total notifications number displayed by VB.That's all :) Really simple, eh?

Opserty
30 May 2008, 12:30
There was an error in your PHP Code (2nd from last line of array):

if($MyNotificationNeedsToBeShown)
{
$notifications['MyNotificationName'] = array(
'phrase' => $vbphrase['MyNotificationName'],
'link' => 'mylinkpage.php',
'order' => 100
);

$vbulletin->userinfo['MyNotificationName'] = $MyNotificationCount;
}

Princeton
30 May 2008, 13:23
thank you!

you should have released this 2 weeks ago - would have come in handy :)

FractalizeR
30 May 2008, 13:49
Thanks for fixing my error.

you should have released this 2 weeks ago - would have come in handy
Yes ;) Just started coded some things for myself and found this nice feature.

silly rabbit
20 Jun 2008, 23:47
Thanks for fixing my error.
Thanks Fract, I guessed right (see here (http://www.vbulletin.org/forum/showpost.php?p=1551301&postcount=407)). Want to change the way vbms email notifies me but still haven't decided what to do for a access menu.

EDIT: It works! Not knowing how to write an xml plugin (yet) I simply edited the "global.php" adding what you see below . . . wrong, I used the plugin manager and imported exact same code as a product ( hehe :confused: first time!)

I left the navbar template alone and the very last line "$vbms_newmessages['newcount'] = 0" stops the original "Email" count display.
($hook = vBulletinHook::fetch_hook('notifications_list')) ? eval($hook) : false;
// vbms add
if ($vbms_newmessages['newcount'] > 0)
{
$notifications['vbms_has_mail'] = array(
'phrase' => $vbphrase['vbms_has_mail'],
'link' => 'vbms.php',
'order' => 1
);
$vbulletin->userinfo['vbms_has_mail'] = $vbms_newmessages['newcount'];
$vbms_newmessages['newcount'] = 0;
}
// vbms add end
Works perfect! If I "read" then "mark as unread" the notification indeed comes back.

Will do an xml plugin next, what else can we hide, use this for? Oh, also, the sound notification hack "you got mail" makes me jump, can anybody point me toward a simple ding/dong chime.wav?

"Your inbox has VBMS email waiting. 1"

Cheers & thanks again, Rabbit

FractalizeR
21 Jun 2008, 10:50
\WINDOWS\Media\chimes.wav :)