N
N
Nikolai Novosad2015-11-22 23:08:57
Yii
Nikolai Novosad, 2015-11-22 23:08:57

Yii2 passing variable in main.php?

Hello.
How can I pass an array received from the database to main.php?
Not in index.php, but in the template. It is necessary to display information in the sidebar, which will be on all pages.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
totudub, 2015-11-23
@totudub

You need a widget.
www.yiiframework.ru/forum/viewtopic.php?f=19&t=33885

I
Ilya Beloborodov, 2015-11-22
@kowap

In the parent controller (which all controllers inherit)

public $data;
public function init(){
   $this->data=[Выбираем то, что нужно]
}

And in the template you call
$this->data;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question