Reputation: 540
I want to set up at least two different themes for guest and for admin user. It also would be handy to have the option to set up different theme for different type of user. For example premium user would see things differently to guest and to admin.
When I try following in /config/main.php:
'theme'=>(Yii::app()->user->isGuest)?'bluebox':'classic',
it always evaluates as false. I guess engine is not initialized yet. Is there any way how to achieve this?
Upvotes: 5
Views: 9535
Reputation: 3950
You can't configure multiple themes in config.php file, you can do this in your controller.
public function init()
{
if(Yii::app()->user->isGuest)
Yii::app()->theme = 'bluebox';
else
Yii::app()->theme = 'classic';
parent::init();
}
Upvotes: 14
Reputation: 6356
Here's a thread on how to change the theme on the fly:
http://www.yiiframework.com/forum/index.php/topic/29619-changing-theme-on-the-fly/
Upvotes: 1