I created a module using Gii, called admin, which I want to use an entirely different layout to the rest of the site.
Now I can’t seem to be able to change the default controller from anything but the ‘protected/views/layouts/main.php’ default. I’ve tried setting the $layout and $layoutPath properties in maybe 20 different ways, and still nothing works. I’ve tried changing it in my AdminModule.php class in both the init() function and declaring "public $layout = ". I’ve tried using Yii::app()->layout and Yii::app()->setLayoutPath() directly, I’ve tried setting it in the config file, and I’ve tried changing the layout in the controller using these methods above. Still, my site will load nothing other than the default ‘main’ view.
This is despite the fact that I’m still getting errors when I attempt to specify an invalid layout path, so it’s obviously parsing my input but not using it.
I’ve searched the forums thoroughly and wasn’t able to find a solution to this problem. Can someone throw me a bone? This is driving me nuts!
public function init()
{
// import the module-level models and components
$this->setImport(array(
'administrator.models.*',
'administrator.components.*',
));
$this->layout = 'admin';
}
make sure your layoutFile ‘admin.php’ is located in modules/admin/views/layouts
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'admin.models.*',
'admin.components.*',
));
$this->layout = 'admin';
}
It’s still showing the protected/views/layouts/main.php layout, I do have an admin.php layout in modules/admin/views/layouts.