Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Using VBulletin 3.7.x notifications engine
FractalizeR's Avatar
FractalizeR
Join Date: Oct 2005
Posts: 368

 

Russia, Moscow
Show Printable Version Email this Page Subscription
FractalizeR FractalizeR is offline 05-29-2008, 10:00 PM

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?
Reply With Quote
  #2  
Old 05-30-2008, 11:30 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;

Reply With Quote
  #3  
Old 05-30-2008, 12:23 PM
Princeton's Avatar
Princeton Princeton is offline
 
Join Date: Nov 2001
Location: Vineland, NJ
Posts: 6,693
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you!

you should have released this 2 weeks ago - would have come in handy
Reply With Quote
  #4  
Old 05-30-2008, 12:49 PM
FractalizeR's Avatar
FractalizeR FractalizeR is offline
 
Join Date: Oct 2005
Location: Russia, Moscow
Posts: 368
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 06-20-2008, 10:47 PM
silly rabbit silly rabbit is offline
 
Join Date: Oct 2005
Location: Atlanta/NYC
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by FractalizeR View Post
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 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
Reply With Quote
  #6  
Old 06-21-2008, 09:50 AM
FractalizeR's Avatar
FractalizeR FractalizeR is offline
 
Join Date: Oct 2005
Location: Russia, Moscow
Posts: 368
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

\WINDOWS\Media\chimes.wav
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:31 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04149 seconds
  • Memory Usage 2,260KB
  • Queries Executed 19 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (2)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete