S
S
sattva20122017-04-22 19:01:52
Yii
sattva2012, 2017-04-22 19:01:52

How to manage title and meta-tag on a website written in YII2?

How to manage title and meta-tag on a website written in YII2?
there is an entrance to the
site.com/backend admin panel
but there I see only a few pages in the "pages" section, how can I change the title on the remaining 300 pages?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry, 2017-04-22
@slo_nik

Good evening.
I can offer two options so far.
First:
Write the content of the required tags in the params.php file and substitute it in the /layouts/main.php template
Second:
Create a table in the database and store the contents in it. Create a settings module where it will be possible to manage the content of tags. An example is here (for yii1, but easily modified for yii2)
The first option is for static data, the second for dynamic data.
The contents of the title tag can be set in a configuration file, and how this file is called depends on which application you are using, basic or advanced.
And a link to the documentation.
Registration of meta tags (English)
Registration of meta tags (Russian)

M
Maxim Timofeev, 2017-04-23
@webinar

What a horror you have there, but the main thing is:
<?= Html::csrfMetaTags() ?>- it just brings them out. And you need to set them in the view (in view/somefolder/index.php, view/somefolder/create.php, etc.), and not in the layout (layout/some_name.php)
Like this:

$this->title = "мой тайтл";
$this->registerMetaTag(['name' => 'description', 'content' => 'мой супер пупер текст']);

And you don't do well with cookies, there are methods built into yii:
www.yiiframework.com/doc-2.0/guide-runtime-session...

S
sattva2012, 2017-04-23
@sattva2012

thanks for the help!
but I'm not a website developer, I'm a system administrator who is tasked with changing the title, description, keywords
Therefore, I ask you to write a step-by-step algorithm for a non-developer, what should be opened for what to
update the title, description, keywords!

I
ivanitch, 2019-12-15
@amurcoder

The easiest way to create and manage meta tags on a website written in YII2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question