The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Adding a site-wide template variable.
Hi,
I am looking to add a template variable that will be usable in all templates. The variable will be an integer between 1-9 that will be random on each page load. I want to use this for site wide "advert page-skinning" for lack of a better term. Basically i want to be able to add something like this to any template: Code:
<vb:if condition="$integer == 3">fu</vb:if> or <vb:if condition="$integer > 5">fu</vb:if> or <vb:if condition="in_array($integer, array(4,8,9))">fu</vb:if> Thanks in advance. |
#2
|
||||
|
||||
Used in *all* templates? So, in the header, and the footer, and the SHOWTHREAD, and ..... In vB4, you need to preregister variables for use in templates, so this may be problematic. You may try piggy-backing on the $bbuserinfo array, but I have no idea if that would work or not.
|
#3
|
|||
|
|||
What got me thinking was that THIS_SCRIPT can be used in all templates cant it? of course I could be wrong
|
#4
|
||||
|
||||
Yes. There are some variables that do not need to be registered like the $bbuserinfo variable I mentioned (along with $session and $vboptions, and I can't remember them all).
|
#5
|
|||
|
|||
I will post my solution for posterity's sake.
I wasnt able to use a variable for all templates but registering vars for templates is pretty easy. I added a plugin to the "parse_templates" hook location: PHP Code:
I am not sure if this is the proper way to do this but it is working for me, I can use {vb:raw ad_int} in the specified templates. Maybe someone can chime in if there is a better way to do it. Cheers |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|