The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help creating a plug-in that puts code into a template
For addition of some "div" content into footer template, I have modified the template. the code for it looks something like this.
<vb:if condition="!empty($threadinfo[threadid])"> <!-- add two scripts --> <div> Some html code </div> <script type="text/javascript" language="JavaScript"> callme("variable1" ,{vb:raw threadinfo.threadid}); </script> </vb:if> I registered $threadinfo in the footer template and it is working fine. But I want to package it into a plug-in and put the same code into the template using that plug-in. So I created a template with above code chunk. I created a product and a plug-in in it: I created the plug-in for the hook "parse_templates" My Plugin code looks like this. $tpl = vB_Template::create('mytemplate'); $template_hook['footer_test_hook'] = htmlentities($tpl->render()); and I put {vb:raw template_hook.footer_test_hook} in the footer template. But nothing seems to render in the thread page. I would really appreciate it if some one guides me to the right way. |
#2
|
|||
|
|||
I think you need to add a line to register threadinfo to your template, like:
Code:
$tpl = vB_Template::create('mytemplate'); $tpl->register('threadinfo', $threadinfo); $template_hook['footer_test_hook'] = htmlentities($tpl->render()); And that will only work if $threadinfo is available at that hook, which I'm not sure of offhand (I guess if you had it working directly in the footer template, then it probably is). Also, I don't think you need the call to htmlentities(). |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|