Answer the question
In order to leave comments, you need to log in
How to work with layuots (working with the dmstr/yii2-adminlte-asset, widget)?
I connected the AdminLTE widget for myself, this is where the question arose since all pages are connected as layouts , how can I transfer data from models to layouts and is it possible to create and how to connect a controller that will transfer data from the database to layouts
Answer the question
In order to leave comments, you need to log in
in controller action write
$this->view->params['model'] = new Model;
//...
//вызывать render, всё как обычно
$model = $this->params['model'];
//... обрабатываем модель
transfer data from models to layouts and is it possible to create and how to connect a controller that will transfer data from the database to layouts
working with dmstr/yii2-adminlte-asset widgetThis is not a widget
since all pages are included as layoutsRave
how to pass data from models to layouts
// Это ужасно и так делать не стоит, но всё же:
// В контроллере
$this->view->params['hello'] = $model;
// В layout
<?= $this->params['hello']['my_attribute'] ?>
how to connect a controller that will transfer data from the database to layoutsMost likely you don’t understand what controllers are for, I would advise you to spend a certain amount of time studying the PHP language, then even more time to understand what MVC is and even more time than in the sum of the previous lessons, spend time reading the Yii2 documentation, best practices and cookbooks in the vastness of the Internet. And then after all this, return to the Toaster to this issue.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question