View Full Version : How to include a template in other template?
Yellow Slider
02-15-2010, 12:39 PM
How can I include a template in other template?
Like in the template 'vbcms_page', the templates 'header', 'navbar', etc, are including by '{vb:raw xxx}'. I tried to do it like this, but it didn't worked. Any help?
Tnx.
Paul M
02-15-2010, 12:47 PM
You have to render the initial template and store it in a variable, then register that variable for use in the second template, and add it into the second template as a raw variable.
Yellow Slider
02-15-2010, 12:53 PM
How do I do it...?
I'll be happy if you will explain a little.
Ryan Ashbrook
02-15-2010, 01:27 PM
INstantiate the template with vB_Template::create
$newtemplate = vB_Template::create ( 'template_name' )->render ( );
Then register it, like normal variables, into the parent template.
$templater->register ( 'newtemplate', $newtemplate );
Yellow Slider
02-15-2010, 01:38 PM
I didn't understand. I tried something, but it isn't working.
Where shpuld I put those codes?
I understand what should I do from Paul M, but I dont know how to do it.
I will be happy id you will explain depper.
Tnx for attitude.
MARCO1
02-15-2010, 02:09 PM
Check this thread : https://vborg.vbsupport.ru/showthread.php?t=228078
Yellow Slider
02-15-2010, 04:03 PM
Got it. but still...:
When im adding the template to a raw variable, and showing it on the template 'vbcms_page', it works.
But when im adding this to the 'header' template, id doens't.
Here is the plugin:
$abcHTML = vB_Template::create('DK')->render();
vB_Template::preRegister('header', array('var' => $abcHTML));
vB_Template::preRegister('vbcms_page', array('var' => $abcHTML));
As you see, the template named 'DK'.
I think the HOOK location isn't good. the location is: process_template_complete.
but if this is really the problem, why? and i will be happy for a little explain about 'HOOK'.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.