S
S
sawa42016-07-08 23:53:37
Yii
sawa4, 2016-07-08 23:53:37

At what level is layout main connected in yii2? Where?

Hello everyone, I can’t understand how the main layout (hereinafter the template) is connected in yii2 advanced.
I need to display another template in all pages that are not the main one.
I do this: I inherit from
the Controller Controller
BaseController extends Controller
here I set:
public $layout = 'myLayoutName';
and all controllers already inherit from BaseController, and in the SiteController actionIndex I write:
$this->layout = 'main';which is by default in advanced yii2 The
question is, am I doing it right? Where and how is the main template connected?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-07-09
@sawa4

Templates in Yii2 can be defined in several places (depending on the need):
1. At the application level (specified in the config, in the $layout parameter)
2. At the module level (specified in the $layout parameter)
3. At the controller level (specified in the $layout parameter) $layout parameter)
If the layout of the module is set, it will be rendered regardless of the layout of the application, if the layout of the controller is set, it will be rendered regardless of the layouts of the application and the module.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question