The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How Can I use a custom template as a variable
Hello everyone, does anyone know how I can use a custom template (for example: COFTW_FAQ) and insert it as a variable into another template (OFTW). I saw this article here https://vborg.vbsupport.ru/showthread.php?t=119933 but it's not working for me with vb4. Anyone know where I can find updated documentation on this? Basically I want to use a custom template inside another template using a plug in. Any ideas anyone? Please help.
|
#2
|
|||
|
|||
<a href="https://vborg.vbsupport.ru/showthread.php?t=228078" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=228078</a>
|
#3
|
|||
|
|||
Quote:
Basically I want to crate a "shell" and then use {vb:raw oftw_faq} (which is the contents of another custom template) inside that template. |
#4
|
|||
|
|||
Scroll down to the section that's labeled "Save into a variable for later use in custom template". Basically you save the output of render() into a variable, then you use it in another template like you would any other variable. If the "including" template is also one you're rendering in your code, then you can just register the variable as you would any other. If you want to include it in one of the existing vb templates, then you probably need to use vB_Template:reRegister() (search for that in the article linked above).
Using examples from the article, PHP Code:
|
#5
|
|||
|
|||
So it would be 2 plug-ins that I wold have to create right? One to render the template as a variable then another to render the variable in the other template?
--------------- Added [DATE]1310141238[/DATE] at [TIME]1310141238[/TIME] --------------- OK this is what I got so far: First Plug-in to register the template into a variable: PHP Code:
PHP Code:
Code:
{vb:raw oftw_faq} |
#6
|
|||
|
|||
It could be two plugins or the same plugin, it just depends on what you're doing (if you're using the same hook location for both, then you definitely don't need two plugins).
Based on the code you posted, you'd need {vb:raw oftw_faq} in the 'COFTW_FAQ' template to see $oftw_faq, and {vb:raw COFTW_FAQ} in the 'OFTW' template to see the first template. Also if you use two plugins, depending on the hook locations, you might need "global $mytemplate2_rendered;" in one or both locations. BTW, you're missing a couple of quotes in the code for the second template. |
#7
|
|||
|
|||
Basically I want to create a "shell" template with OFTW. With OFTW being the main template and using COFTW_FAQ template as an insert into OFTW. The script that uses OFTW is oftw.php and I just created template COFTW_FAQ with the following contents which I want to insert into OFTW:
HTML Code:
<div class=block> <h2 class=blockhead>F.A.Q</h2> <div class=blockbody>Hello </div> </div> Updated Plug-ins: (still not working ) (both with global_start as hook) PHP Code:
PHP Code:
|
#8
|
|||
|
|||
If you're using the same hook location then you should probably just use one plugin. But if you want to use two for whatever reason, then you should set the execution order fields so that they run in the order you expect.
But if you've created a php file called oftw.php, then you may not need to use plugins at all, just put the code you need in the file. There's nothing magic about a plugin, it just lets you add code without editing the existing php files. |
#9
|
|||
|
|||
Quote:
Code:
<li class="usercp_nav"><a href="JavaScript:void()" onclick="document.getElementById('DivExample').innerHTML = '<p>{vb:raw COFTW_FAQ}</p>';">F.A.Q</a></li> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|