S
S
Sergey2015-03-01 19:19:38
Yii
Sergey, 2015-03-01 19:19:38

How to find out the main page in view layout yii2?

How to determine in Yii2 that the page is the main one in the view file?
At the same time, you need to define it in view/layout/main.php

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Bay, 2015-03-01
@butteff

If I understand correctly, then you need to find out the name of the controller in main.php, then:

if ((Yii::app()->controller->id == 'site') and (Yii::app()->controller->action->id == 'index'))  {
// тут код
}

M
Maxim Kolokolnikov, 2015-03-01
@maxmirazh33

Yii::$app->request->url == Yii::$app->homeUrl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question