V
V
Vitaly2017-07-03 10:19:47
Yii
Vitaly, 2017-07-03 10:19:47

How to pass title and description to title?

Good morning. I have my own title, description, keywords in the database for different types of pages. How can I pass them to the title so that the page does not display a sticky title, but the one that is registered in the database for a specific category of the page,
I try to display all this like this

$this->title = $model->meta_title;
$this->registerMetaTag(['name' => 'description', 'content' => $model->meta_description]);
$this->registerMetaTag(['name' => 'keywords', 'content' => $model->meta_keywords]);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2017-07-03
@kat-vetal

You are doing everything right. If this code is in the view and if there is an output in the layout (give the layout code).

B
Boris Korobkov, 2017-07-03
@BorisKorobkov

From controller - $this->view->title.
From the view -$this->title

A
Anton, 2017-07-03
@Eridani

This is how you form the resulting data array collected from the model in the controller and send it to the view.
So shove the meta data into your array keys, and print out in the view
<title><?=($title ? $title : '');?></title>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question