PDA

View Full Version : How to add to the header template?


DragonBlade
01-25-2010, 09:41 AM
M'kay, I need to register a variable with the 'header' template, but I'm not quite sure just where to do it. Could someone gimme a heads up?

I just need to know whereabouts I'd be putting
$theTemplateObj->register('myvar', $myvar);
for the header template.

Doing searches for it kind of lead me to a bunch of unrelated stuff. :<

--------------- Added 1264423069 at 1264423069 ---------------

Update:

A little more searching tells me that I am supposed to "preRegister" variables for existing/stock templates. That's good, I'm getting somewhere, heh.

So, here's what I have:


/// A bunch of my other code


$cba_main_template = vB_Template::create('cba_main');
$cba_main_template->register('cba_announcements', $cba_announcements);
$cba_main_template->register('cba_id', $cba_id);
$cba_main = $cba_main_template->render();
vB_Template::preRegister('header',array('cba_main' => $cba_main));

I believe this is the right syntax, but I must be putting it in the wrong place, as it's not adding anything to the header template. :<

--------------- Added 1264429257 at 1264429257 ---------------

Apparently, the answer seems to be to put such things on the parse_templates hook. Maybe that's only with the header template, but that's the only way I could get it to work. :/

Paul M
01-25-2010, 09:33 PM
That sounds about right, its the hook called just before the header is rendered.