Quote:
Originally Posted by Abe Babe
Code:
$templater = vB_Template::create('layout_start');
$templater->register('my_var', $my_var);
$templatevalues['start_insertvar'] = $templater->render();
vB_Template::preRegister('FORUMHOME', $templatevalues);
I have two questions. Is there any way to preRegister for more than one pre-existing template (or a global registration), or do I have to create Plugins for every page I want to add this to (*groan*)?
|
Just calling the preregister method as often as you need it might not work in this case, since the method clears the variable. So trying to simply preregister it again might not be feasible. Anyway, try this:
Code:
$templater = vB_Template::create('layout_start');
$templater->register('my_var', $my_var);
$templatevalues['start_insertvar'] = $templater->render();
vB_Template::preRegister('FORUMHOME', $templatevalues);
vB_Template::preRegister('SHOWTHREAD', $templatevalues);
vB_Template::preRegister('FORUMDISPLAY', $templatevalues);
If this does not work, try something like this:
Code:
$templater = vB_Template::create('layout_start');
$templater->register('my_var', $my_var);
$start_insertvar = $templater->render();
$templatevalues['start_insertvar'] = $start_insertvar;
vB_Template::preRegister('FORUMHOME', $templatevalues);
$templatevalues['start_insertvar'] = $start_insertvar;
vB_Template::preRegister('SHOWTHREAD', $templatevalues);
$templatevalues['start_insertvar'] = $start_insertvar;
vB_Template::preRegister('FORUMDISPLAY', $templatevalues);
Of course, if you have really many templates, it might be more elegant to solve this with an array an a nice loop.
Quote:
And what is the best hook to have this on. I am currently using 'parse_templates'.
|
Seems fine to me.