Different layouts as per action and as per logged in status

i want my controller actions to have different layouts ie. each action will have its own layout.

I have tried the below code




public function actionShortsearch()

	{

		

$layout='//layouts/column2';


}

but have not been succesfull

Also I want different layouts to come when a person is logged in

Any help?

Any Ideas?

You can overridde beforeAction() in your base controller (components/Controller.php). You receive a CAction object as argument, so you can check the action Id. You can also check the user status and set $this->layout (not $layout!) accordingly.

EDIT: And remember to return true, or it will cancel the action.

Oh, and if you just want to override your layout in some actions, you don’t need to override beforeAction - just set it with $this->layout in the respective action.

Thanks

how can i do that??? still no luck




    public function actions() {

        $getPage=$_GET['view'];

        $column=$this->_setLayoutPage($getPage);

        $this->layout="//layout/$column";


        return array(

            // captcha action renders the CAPTCHA image displayed on the contact page

            'captcha' => array(

                'class' => 'CCaptchaAction',

                'backColor' => 0xFFFFFF,

            ),

            // page action renders "static" pages stored under 'protected/views/site/pages'

            // They can be accessed via: index.php?r=site/page&view=FileName

            'page' => array(

                'class' => 'CViewAction',

            ),

            'loader' => array(

                'class' => 'LoaderAction'

            ),

        );

    }




    private function _setLayoutPage($page){

        return "column-aboutus";

    }



what i want to achive is. the page got group by menu. but i want to got different look.

trying change using $this->layout with no luck