PDA

View Full Version : How to know what template was loaded?


RedFoxy
12-10-2009, 11:43 AM
Hi all!
I want write a plugin (admincp ->Plugins & Products -> Add New Plugin) to manage some variables that I'll print it in template, my code will prepare the variables only for the templates that will be loaded in current page, like, if the template "ad_showthread_firstpost_start" will be loaded in current page, my code will prepare the variables for that template, if the template "pm_messagelistbit" will be loaded, my code will prepare the variables for "ad_navbar_below" and not for "ad_showthread_firstpost_start" etc...

But to do that, I need to know what template will be loaded in current page... There is an array or something with current templates names? (not whole templates, only the group that will be loaded in current page)

mme42
12-10-2009, 12:39 PM
There's a setting in the vbulletin options to show template names in the html source.

vBulletin Options > General Settings > Add Template Name in HTML Comments = Yes

You can then look at the html source and see the template names in html comments for whatever page.

Lynne
12-10-2009, 02:06 PM
If you go into debug mode, then the list of templates used on each page it printed at the bottom of the page.

RedFoxy
12-10-2009, 03:02 PM
I need in php not in HTML or debug and I need it to use to check if i must run a a code or another.

Like:
if ad_xyz is loaded then
$variable = "123445df";
else if ad_bass is loaded then
$variable "ambbma";
else
$variable = "qwerqqwer";
end if

kh99
12-10-2009, 03:05 PM
If you know which templates are used in which php files, you could test the value of THIS_SCRIPT.

RedFoxy
12-10-2009, 03:57 PM
there isn't an array or similar to know the template?

kh99
12-10-2009, 04:19 PM
I think there are arrays which tell you what templates are cached, but that doesn't necessarily equal the templates that are actually used. There seems to be a number of arrays and I'm kind of fuzzy on that whole area. Probably Lynne knows the answer. :)

Lynne
12-10-2009, 04:23 PM
Probably Lynne knows the answer. :)
Nope. I've never looked into this before so I don't know the answer. :)