Quote:
Originally Posted by Abe Babe
I have a template that I need to insert into multiple pre-existing templates. After a bit of struggling, I have managed to get the following code running.
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*)? And what is the best hook to have this on. I am currently using 'parse_templates'.
|
------------------------------------
I'm doing this using
$GLOBALS[templatevalues] = $templatevalues; rather than preRegister().
Code:
$templater = vB_Template::create('layout_start');
$templater->register('my_var', $my_var);
$templatevalues['start_insertvar'] = $templater->render();
$GLOBALS[templatevalues] = $templatevalues;
UPDATE: (Thanks to kh99 for his guidance.)
The following line isn't needed and was used incorrectly:
$template->register_global('templatevalues');
Then use this in the templates where you want the output to appear:
Code:
{vb:raw GLOBALS.templatevalues.start_insertvar}
Be Well