PDA

View Full Version : Calling other templates


dvsDave
09-15-2010, 12:21 PM
Is there a way to call other templates?

Basically, is there a way to do this:

<vb:if condition="$bbuserinfo[fieldx] != 'Vertical'">

vb:template postbit;

<vb:else />

vb:template postbit_legacy;

</vb:if>

compwhizii
09-15-2010, 12:31 PM
No, you have to do that in your code.

dvsDave
09-15-2010, 12:55 PM
In the GENERIC_SHELL template, they call certain templates


{vb:raw headinclude}
<title>{vb:raw pagetitle}</title>

<vb:if condition="$includecss">
<vb:if condition="$vboptions['storecssasfile']">
<vb:each from="includecss" value="file">
{vb:cssfile {vb:raw file}}
</vb:each>
<vb:else />
{vb:cssfile {vb:raw includecss}}
</vb:if>
</vb:if>
{vb:raw headinclude_bottom}

Does that only work for some templates, or can I reuse this format to insert the template of my choice?

Lynne
09-15-2010, 01:54 PM
It works if you have already rendered the template and then you need to register the variables for use in that template (it is actually calling a variable with the same name as a template, not calling a template).

dvsDave
09-15-2010, 02:09 PM
My thought is to copy the postbit to a new template called postbit2, then put the above code in the postbit.

How can I render the two templates (postbit_legacy and postbit2), or choose which template to use then render one of them?

compwhizii
09-15-2010, 02:11 PM
You need to fetch the remplate and register it in your code.

ragtek
09-16-2010, 05:28 AM
Stop!!!!
Just check, how vB is handling the postbit templatess;)

It's much easier to change $vbulletin->options['legacypostbit'] !

Lynne
09-16-2010, 01:38 PM
^^ What he said. That is the option that determines which postbit template gets used. So, toggle it depending on what the user has selected.

dvsDave
09-16-2010, 03:13 PM
Stop!!!!
Just check, how vB is handling the postbit templatess;)

It's much easier to change $vbulletin->options['legacypostbit'] !

That's what I was hoping to find in the first place. Unfortunately, I'm still learning the vBulletin template/coding system.

Where would I find this and how can I access the user's preferences to switch the option?

-David

Lynne
09-16-2010, 05:50 PM
Did you use a User Profile Field for them to pick which to use? Just do a condition based on that field to change it for the user. Look in the showthread.php file to find a good hook. Or, if in debug mode, you can see the hook locations all listed on the bottom of the page in the order they are used. Sometimes I find myself just going down the list to see which is best.

dvsDave
09-16-2010, 07:02 PM
Did you use a User Profile Field for them to pick which to use? Just do a condition based on that field to change it for the user. Look in the showthread.php file to find a good hook. Or, if in debug mode, you can see the hook locations all listed on the bottom of the page in the order they are used. Sometimes I find myself just going down the list to see which is best.

So, I'm looking for a hook location that is right before the postbit is called?

Lynne
09-16-2010, 11:45 PM
Yes, you want one for when the page is called - before the postbits are rendered.