vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Using VBulletin 3.7.x notifications engine (https://vborg.vbsupport.ru/showthread.php?t=181007)

FractalizeR 05-29-2008 10:00 PM

Using VBulletin 3.7.x notifications engine
 
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:

PHP 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 05-30-2008 11:30 AM

There was an error in your PHP Code (2nd from last line of array):
PHP Code:

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

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



Princeton 05-30-2008 12:23 PM

thank you!

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

FractalizeR 05-30-2008 12:49 PM

Thanks for fixing my error.

Quote:

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 06-20-2008 10:47 PM

Quote:

Originally Posted by FractalizeR (Post 1536196)
Thanks for fixing my error.

Thanks Fract, I guessed right (see here). 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) [S]I simply edited the "global.php" adding what you see below[/S] . . . 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.
PHP Code:

($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 06-21-2008 09:50 AM

\WINDOWS\Media\chimes.wav :)


All times are GMT. The time now is 10:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01216 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete