Answer the question
In order to leave comments, you need to log in
Yii2: Is it possible to make the parameters passed to View available in layout-e?
Parameters are passed from the Controller to the View like this:
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'header' => 'lalala',
]);
Answer the question
In order to leave comments, you need to log in
just put similar layout'a content into the widget) and you won't need to do complicated manipulations
This is done through the View parameters, although you can get confused and render without layout, and write the layout itself and the $view render method in the view, then additionally pass a parameter, for example, 'view' => 'index'. But it is necessary to deepen the folder structure apparently.
I searched for you on google, like what you need: stackoverflow.com/questions/28038912/how-to-pass-p...
In the parent controller (in the controller that inherits the current controller):
In the action that renders the view:
And now in the main template (layout) output like this:echo $this->params;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question