Answer the question
In order to leave comments, you need to log in
How to add a new menu item for a guest?
In the menu widget in the basic YII2 template, there is a check for a guest and if you are a guest, the Login item is displayed, but how to add more items?
Yii::$app->user->isGuest ? (
['label' => 'Вход' , 'url' => ['/site/login']]
//как вставить еще один пункт сюда
) : ()
Answer the question
In order to leave comments, you need to log in
Don't use ternary operator?
if (Yii::$app->user->isGuest) {
$menu[] = ['label' => 'Вход' , 'url' => ['/site/login']];
$menu[] = ['label' => 'Регистрация' , 'url' => ['/site/signup']];
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question