The one with the CRUD operations.
It’s getting on my nerves, I delete all the items and the header is still there.
The one with the CRUD operations.
It’s getting on my nerves, I delete all the items and the header is still there.
In your site’s base controller you can add
<?php
public function getLayoutFile($layoutName) {
if($this->menu){
return Yii::getPathOfAlias('application.views.layouts')."/column2.php";
} else {
return Yii::getPathOfAlias('application.views.layouts')."/column1.php";
}
}
?>
this will use the layout with the menu if there are menu items or the layout without the menu if there are not any menu items
Is there a way whereby you can set a particular layout for each action in a controller?
for example…
actionCreate
render with layout colomn2
actionRegister
render with layout colomn1
At this stage at the end of my action i have;
$this->render('register', array(
'user'=>$user,
'email'=>$email,
));
At the start of controller i have a default setting;
public $layout='application.views.layouts.column2';
How do I make the action render with
'application.views.layouts.column1';
SOLVED
$this->layout='column1';
$this->render('register', array(
'user'=>$user,
'email'=>$email,
));
I found this topic while looking for how to affect which items that is added to the $model->menu member. I first though it might have to do with access levels, but it is actually set in each view-file created by the CRUD generator.
Example code:
$this->menu=array(
array('label'=>'List Comment', 'url'=>array('index')),
array('label'=>'Create Comment', 'url'=>array('create')),
);
By adding/subtracting items to this list, items can be added/removed.
(I know this thread is several months old, but I found it through google while searching for an answer to my question - so posting this tip if someone else wonders the same)