1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Different style per domain (code example) 1.x

Lets you override the style choice of the user, in this example by domain name.

  1. Jake Bunce
    I made this simple addon to override the style choice by domain name. You need to edit the library/StyleOverride/Listen.php file to specify the domains and their style_ids:

    Code:
    <?php
    
    class StyleOverride_Listen
    {
    	public static function listen(XenForo_Controller $controller, $action)
    	{
    		$visitor = XenForo_Visitor::getInstance();
    		$host = $controller->getRequest()->getServer('HTTP_HOST');
    
    		if ($host == 'www.domain1.com')
    		{
    			$visitor['style_id'] = 3;
    		}
    		else if ($host == 'www.domain2.com')
    		{
    			$visitor['style_id'] = 2;
    		}
    		// DEFAULT STYLEID, IF NONE OF THE DOMAINS MATCH
    		else
    		{
    			$visitor['style_id'] = 3;
    		}
    	}
    }
    
    Also, all of the style_ids you set must be user-selectable:

    Screen shot 2011-12-13 at 9.09.39 PM.png

    Of course this code can be changed to use any other conditions you wish.

Recent Reviews

  1. whitemorn
    whitemorn
    5/5,
    Version: 1.x
    Works like a charm on 1.3.1
  2. ExpertPixels.com
    ExpertPixels.com
    5/5,
    Version: 1.x
    Actually CRDeveloper has a great point :) I was trying to suss out the usage of this.. but yes weel done :) TY
  3. CRDeveloper
    CRDeveloper
    5/5,
    Version: 1.x
    Good for mobile redirection!!!