Yii Framework Forum: Dynamic Theme Based On Url - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Dynamic Theme Based On Url Rate Topic: -----

#1 User is offline   ridz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 05-August 11

Posted 12 December 2012 - 08:02 PM

Hi,

How can I set a theme based the URL? I've tried amending /protected/config/main.php with the code below but it doesn't work. $mytheme did not set to 'mobile' when I access the page at http://m.example.com.


$mytheme = 'classic';
 if (Yii::app()->request->hostinfo=='http://www.example.com/')
 	$mytheme = 'classic';
 if (Yii::app()->request->hostinfo=='http://m.example.com/')
 	$mytheme = 'mobile';

return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'Example',
	'theme'=>$mytheme,

...


Any help is appreciated. Thanks.

regards,
Ridz
0

#2 User is offline   ridz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 05-August 11

Posted 12 December 2012 - 08:27 PM

Hi,

Solved the problem. See code below.

$mytheme = 'classic';
 if ($_SERVER['HTTP_HOST']=='http://www.example.com')
        $mytheme = 'classic';
 if ($_SERVER['HTTP_HOST']=='http://m.example.com')
        $mytheme = 'mobile';

return array(
        'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
        'name'=>'Example',
        'theme'=>$mytheme,




regards,
Ridz
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users