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=';)' />

			'model'=>$model,

		) );

	}



and in the view




<?php

$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');

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

			'dataProvider'=>$dataProvider,

		));

	}




or just do the following in view.




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



no need to pass as data to view file.

Regards.

That solution doesnt work

I eventually put




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



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