Switch Layout Dynamically

Running: yii-1.1.10.r3566

I would expect CController->layout to be passed to any render() command, but it seems this is not the case.

I have the following:

class ActionController extends Controller {

	public $layout='column2';


	public function actionView() {

		$this->layout = 'column1'; // <-- this has no effect


		$this->render( 'view', array(

			'layout'=>'column1', // <-- this has no effect (this would actually create a $layout variable, but I was just trying my luck... <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' />


		) );


and in the view


$this->layout='column1'; // <-- [b]only this[/b] forces the layout to be changed

My expectation is that layout should be changeable by the CController - it is public after all!!

Question: is this a bug?

Dear Friend

It should be

public function actionIndex()

	{       $this->layout="//layouts/column1";

		$dataProvider=new CActiveDataProvider('Game');





or just do the following in view.


no need to pass as data to view file.


That solution doesnt work

I eventually put


[size="2"]… in the controller and it worked for me.[/size]