Multiple Themes

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 thinks differently to guest and to admin.

When I try following:

‘theme’=>(Yii::app()->user->isGuest)?‘bluebox’:‘classic’,

in /config/main.php it always evaluates as false. I guess engine is not initialized yet. Is there any way how to achieve this?

In your case it’s probably best to use protected/components/Controller.php

Create an init() function below your public variables:


public function init()

{

    parent::init();


    Yii::app()->theme="your_theme";

}

Complementing outrage’s post:




public function init()

{

    parent::init();


    Yii::app()->theme=Yii::app()->user->isGuest?'bluebox':'classic';


}



Happy Coding.

Thanks :) I didn’t go that far because the OP had already spoke of “at least two different themes” so there would need to be some refactoring. Can never be sure of a users understanding though so you’re quite right.