Hi all,
I’ve just started working with Yii nad I’ve found something that doesn’t work like I expected after reading the manual.
I’ve got an AdminModule, extending CWebModule in modules/admin/AdminModule.php
I’ve got a layout: modules/admin/views/layout/main.php
I want all controllers in this module to use this layout. So I’ve added the following property in the class AdminModule (and didn’t add anything to the DefaultController):
public $layout = "main";
When I open index.php?r=admin, the default layout from Yii is used.
However, if I set the property mentioned above in the DefaultController in modules/admin/controllers/DefaultController.php, the correct layout is used.
The documentation about CWebModel->layout is:
the layout that is shared by the controllers inside this module. If a controller has explicitly declared its own layout, this property will be ignored. If this is null (default), the application’s layout or the parent module’s layout (if available) will be used. If this is false, then no layout will be used.
PS: adding $this->layout = “main” in the public function init() from the AdminModule doesn’t work either.
Have I misinterpreted the usage of the layout property in the CWebModel?