Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii using multiple themes

Tags:

yii

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?

like image 839
Mamadum Avatar asked Aug 06 '12 21:08

Mamadum


1 Answers

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();
}
like image 161
Onkar Janwa Avatar answered Nov 03 '22 01:11

Onkar Janwa