Answer the question
In order to leave comments, you need to log in
YII2: How to make a Module Level Layout?
There is a backend application.
1. Layout, main, application level. The backend has its own, main layout (with doctype, body ...). It lies in backend\views\layouts\main.php . Inside it there is an area, let's say "module content" (like Joomla, it has a template, and inside it is an area for Joomla components). Those. there is a part of the template that does NOT change from module to module (admin menu, admin footer, auxiliary tools at the top).
2. Module Level Layout. Next comes the Module, which should also have a layout, "module level". Those. that part of the module that does NOT change from Controller to Controller (within the module) Eg. module admin menu.
3. Further there is directly view of the Module.
(on the example of Joomla c2n.me/3sdYF2UHighlighted in red - Layout, main, application level. Blue - Module-level Layout. Green - directly the Body of the Module. (Black - the Module itself))
If I set the layout='ModuleLayout' property in the bootstrap class of the Module, then it sets it for the ENTIRE application, as the MAIN one.
Actually a question. How to make this very Module-level Layout in YII2?
Answer the question
In order to leave comments, you need to log in
For a module, the same redefinition as for controllers. In this way. If layout is not overridden for a module, it will use it in the application layer.
for the path @backend/views/layouts/post.php
namespace app\controllers;
use yii\web\Controller;
class PostController extends Controller
{
//
public $layout = 'post';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question