Yii Layout And Rendering

Hi, I’m a bit confused with yii $this->render. Can you help me out?

So this is my situation:

I have 3 user types, each of the user types have different views when they sign in.

So basically their layouts is different right?

So is it perfectly logical to create different layouts for different user types OR to create different pages for the user type?

If it makes sense for your application it is perfectly logical to have both custom layouts and views for each type of user. Just make sure you call $this->layout=’//layouts/customlayout’ (or whatever) at the beginning of the controller action that handles the custom view (the recipient of the render() method in the login action).

you can use beforeControllerAction




public function beforeControllerAction($controller, $action)

	{

		$roles=Rights::getAssignedRoles(Yii::app()->user->Id); // check for single role

					

						  foreach($roles as $role)

						  {

							   if(sizeof($roles)==1 and $role->name == 'parent')

							   {

								 $controller->layout='none';

							   }

							   if(sizeof($roles)==1 and $role->name == 'student')

							   { 

								 $controller->layout='studentmain';

							   }

							   if(sizeof($roles)==1 and $role->name == 'teacher')

							   { 

								 $controller->layout='teachers';

							   }

						  }