![]() |
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> Thanks in advance. |
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.
|
What got me thinking was that THIS_SCRIPT can be used in all templates cant it? of course I could be wrong
|
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).
|
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 |
All times are GMT. The time now is 10:37 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|