Automatic Style Switch

  • Thread starter Thread starter Deleted member 2163
  • Start date Start date
D

Deleted member 2163

Guest
Hi all,

Is there a way I can automatically switch the theme via the URL? For example, let's say I have two domains, websiteA.com and websiteB.com. I want websiteA.com to have one theme, and websiteB.com to have a different theme, but both point to the same directory on the server (and hence the same installation of XenForo).

I know you can use /misc/style?style_id={insert style id # here}, but it gives you a page that asks you to confirm use of the theme.

Is there a way I can automatically switch the style, either via URL/htaccess or plugin?
 
I modified the Listener, into:


<?php

class StyleOverride_Listen
{
public static function listen(XenForo_Controller $controller, $action)
{
$visitor = XenForo_Visitor::getInstance();
$host = $controller->getRequest()->getServer('HTTP_HOST');

if ($visitor['user_id'] == 0 || $visitor['user_state'] != 'valid')
{
$visitor['style_id'] = 1;
}
else
{
$visitor['style_id'] = 9;
}
}
}

Is that correct ?
 
Should I remove this codes:

$visitor = XenForo_Visitor::getInstance();
$host = $controller->getRequest()->getServer('HTTP_HOST');

Or it is still needed their ?

In your case only the $visitor line is needed. The $host line can be removed.

I got some problem, when this addon enabled, Even registered users cannot change their styles :(

Correct. The addon forces a style on your users such that they cannot change their style.
 
Top Bottom