D
D
des1roer2015-04-06 12:16:43
Yii
des1roer, 2015-04-06 12:16:43

Yii change layout in controller?

people tell me how to do the following in the controller?

If ($_GET['mode'] == 1 ) public $layout='//layouts/column2';
else public $layout='//layouts/column1';

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
des1roer, 2015-04-06
@des1roer

You can put the code that changes the $layout field in your controller action:

public function actionIndex($mode)
{
    if ($mode == 1)
        $this->layout = "//layouts/column2";
    else
        $this->layout = "//layouts/column1";

        $dataProvider=new CActiveDataProvider('Passport');
    $this->render('index',array(
      'dataProvider'=>$dataProvider,
    ));

V
Vit, 2015-04-06
@fornit1917

If ($_GET['mode'] == 1 ) {
  $this->layout='//layouts/column2';
} else {
  $this->layout='//layouts/column1'; 
}

M
Mikha Pankratov, 2015-04-06
@frmax

Still needs to be announced.
public $layout;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question