V
V
vostotskiy2017-06-27 10:32:35
Yii
vostotskiy, 2017-06-27 10:32:35

Is it possible in Yii2 to automatically generate a title for a page hierarchy?

Hello. I tried to find in the documentation options for implementing automatic construction of titles for project pages. I would like the title structure to be formed according to the principle "site_name | title of pages_first_level" and so on (nesting may change). Of the solutions, I found only custom by type

<title><?= Yii::$app->name ?> | <?= Html::encode($this->title) ?></title>

Does Yii2 have a built-in solution for building titles, or do I need to use third-party components for this purpose? Or do you need to implement your own solution?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-06-27
@qonand

Does Yii2 have a built-in solution for building titles, or do I need to use third-party components for this purpose?
There is no built-in mechanism in Yii2 that implements your task, look for ready-made extensions
No need to reinvent the wheel, first look for ready-made extensions, for example here , and if you don’t find anything suitable for you, then it makes sense to think about writing your own component

M
Maxim Timofeev, 2017-06-27
@webinar

For these purposes, there are breadcrumps, not a title. Why shove it into the title? Let me remind you that the length of the title should ideally not exceed 71 characters. But if you really need it, you can make a widget on the same principle as breadcrumps is built.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question