XF 2.0 Change theme based on sub domain

Jean-Baptiste

Well-known member
Hello,

I have two domains :
example.forum.com
tutorial.forum.com.

I would like to change the theme based on the domain, on the fly.

My problem is the the domain checking part, but the theme switching part.

I tried a lot of things, like changing the style_id in the visitor preferences object, or even that kind of code in a listener :
Code:
$style = new \XF\Style($selectedTheme['style_id'], $selectedTheme['properties'], null, array());
$app->style($selectedTheme['style_id']);

But it's not working.

Any ideas ?
 
Untested, but try hooking the dispatcher_pre_render event and setting the style ID page parameter on the reply object:

PHP:
// set $styleId based on domain
$reply->setPageParam('style_id', $styleId);

You may want to check if the parameter is already set first, to ensure per-node styling options and such still work as expected.
 
Back
Top Bottom