PDA

View Full Version : Wont let me add to template var {vb:raw notifications_menubits}'s value in a plugin


macmee
01-28-2012, 02:49 AM
{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_Shot_2012-01-27_at_4.31.34_PM-20120127-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:


$variabletest = 'llllllllllllllllll';
vB_Template::preRegister('header',array('notificat ions_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:

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

macmee
01-28-2012, 03:32 PM
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:

vB_Template::preRegister('header',array('notificat ions_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:

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.