I created my e-shop module, but I have a problem. To make this module reusable I need to define the layout in the project and not in the module as it is currently the case for my connection system.
But I don’t know how to do this I tried several things, extending the module controller and defining the layout but without success. I could rewrite the action in question to adapt the layout however it wouldn’t make sense for a module to rewrite a controller.
To give an example i have my UserController in my module with the basic actions actionLogin actionRequest actionRegister with no layout assigned.
and in my project I have extended the UserController with an init() function:
public function init()
{
$this->layout = '@app/views/layouts/blank';
parent::init();
}
but it doesn’t work.
If you have documentation or a track I’m interested.
Thank you very much for reading me. And sorry for my poor English.
class UserController extends \shop\frontend\controllers\UserController
{
public function init()
{
parent::init();
$this->layout = '@app/views/layouts/blank';
}
}
I don’t know about the view thing so far, but I tried to change the layout in a module.
(I don’t have my own module so I tried gii DefaultController)
Use the Yii debugger to check which layout file is loaded.
(last two lines in Logs are view and layout).