S
S
Sergey Beloventsev2016-04-29 14:12:57
Yii
Sergey Beloventsev, 2016-04-29 14:12:57

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

3 answer(s)
D
Decadal, 2016-04-29
@Decadal

in controller action write

$this->view->params['model'] = new Model; 
//...
//вызывать render, всё как обычно

in layout:
$model = $this->params['model'];
//... обрабатываем модель

E
Elena Stepanova, 2016-04-29
@Insolita

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

This is what widgets are for.

N
Nikita, 2016-04-30
@bitver

working with dmstr/yii2-adminlte-asset widget
This is not a widget
since all pages are included as layouts
Rave
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 layouts
Most 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 question

Ask a Question

731 491 924 answers to any question