PDA

View Full Version : How to insert custom template into vB 4.1 template


SiteTalkZone
02-13-2011, 12:22 PM
Hi,
I use vB4.1
I'd like customize my sidebar on memberinfo page. I would like add a custom template that I created before into somewhere in sidebar.
I create a new template called name 'mycustomtemplate'

<h2>{vb:raw testVarName}</h2>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>


And then, I create 2 new plugin, the first plugin use hook location: member_build_block_start, with following code:

$testVarName = 'testValue';
$templater = vB_Template::create('mycustomtemplate');
$templater->register('testVarName', $testVarName);
$templater->render();


And the second plugin use hook localtion is cache_templates to register my custom template and it has following code:
$cache[] = 'mycustomtemplate'

Final, in MEMBERINFO template (reserved template of vB), I inserted following code into the position that I want to add my custom template.
{vb:raw mycustomtemplate}


However, when I visit my profile page, my custom template's content cannot be displayed.
I don't know what and where my problem is.

Please check and help me for this issue.

Thanks!

SiteTalkZone
02-15-2011, 12:41 AM
Fixed:
In plug-in, I added following code:
$testVarName = 'testValue';
$templater = vB_Template::create('mycustomtemplate');
$templater->register('testVarName', $testVarName);
$customtemplate = $templater->render();
vB_Template::preRegister('MEMBERINFO', array('mycustomtemplate' => $customtemplate));