Style name checking in addon

niden.net

Member
Greetings,

Is there a way to detect the style name variable (or id)? I have seen the {$visitorStyle.title} in a template but how am I going to get access to that property in the addon?

I am trying to use the template_hook to inject some HTML in my footer based on the style selected.

Thanks!
 
You can get the style id with the visitor object
PHP:
$visitor = XenForo_Visitor::getInstance();
$styleId = $visitor['style_id'];
 
Strictly, the counterpart to "{$visitorStyle.title}" in code would be:
PHP:
$params = $template->getParams();

// id stored in 'style_id'
$styleTitle = $params['visitorStyle']['title'];
(assuming you have named the 4th parameter as $template)

Although I haven't checked what's the difference between grabbing the style id from visitor object
and from the style information stored in "visitorStyle".
 
Top Bottom