vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Wont let me add to template var {vb:raw notifications_menubits}'s value in a plugin (https://vborg.vbsupport.ru/showthread.php?t=277667)

macmee 01-28-2012 02:49 AM

Wont let me add to template var {vb:raw notifications_menubits}'s value in a plugin
 
{vb:raw notifications_menubits} is a variable in the header template. I am making a plugin and require adding additional content to this variable (it's the one that *should* stick content where I have drawn this red line http://davzy.com/screenshots/Screen_...127-163152.png). I created a plugin and have tried both global_start and parse_template as hooks but the following never displays anything when I load my forum index:

Code:

$variabletest = 'llllllllllllllllll';
vB_Template::preRegister('header',array('notifications_menubits' => $variabletest));

All I'd like to accomplish here is being able to add text to the popup which comes up when you hit "notifications" at the top of the page, through a plugin I am writing. Any advice would be greatly appreciated!

kh99 01-28-2012 10:33 AM

I don't know if this is the only problem (or if it's just a typo) but you need a '$' before variabletest in the preRegister call, like:

Code:

vB_Template::preRegister('header',array('notifications_menubits' => $variabletest));

macmee 01-28-2012 03:32 PM

Quote:

Originally Posted by kh99 (Post 2293398)
I don't know if this is the only problem (or if it's just a typo) but you need a '$' before variabletest in the preRegister call, like:

Code:

vB_Template::preRegister('header',array('notifications_menubits' => $variabletest));

Thanks for spotting that, yeah it was just a typo. The problem still persists :(

Lynne 01-28-2012 04:17 PM

Why not add directly to the $notifications array using the notifications_list hook location?

kh99 01-28-2012 04:18 PM

It seems your problem is that the notification menu is built and the header template rendered without any hooks in between, so no matter which hook location you choose you can't get in between them to change it. The only thing I can figure out (and I've never actually tried this) is to use hook location template_render_output and something like:

Code:

if ($this->template == 'header')
{
  // code to change $notification_menubits
}


Seems like it should work, I've just never tired it. Also, of course, if all else fails you can always just edit the vb files. :)


ETA: Or you could try what Lynne suggests above (which she posted while I was writing), but I looked at that and it looks like it would have to correspond to a userfield with a value > 0, and you'd end up with a number following your text.


All times are GMT. The time now is 12:27 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.01041 seconds
  • Memory Usage 1,720KB
  • 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
  • (4)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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