Answer the question
In order to leave comments, you need to log in
How to pass object from controller to head?
Greetings. Help me deal with one issue: you need to pass an object with data from sql to views -> layouts -> main.php (where the head is located). Usually in the controller I take data from the database and pass it to views via return $this->render(). I also need to take the data from the database (a list of cities in a normal sql table) and pass the object with the data to (which is wrapped by $this->beginPage())
Answer the question
In order to leave comments, you need to log in
We look in the dock
// в контроллере
$this->view->params['customParam'] = 'hello Yii!';
// в представлении, включая главный лэйаут
echo $this->params['customParam'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question