Answer the question
In order to leave comments, you need to log in
Working with aliases and navbar?
I created an alias that leads to the backend. If I write it in the link, then everything works, but if in the navbar, then the alias value is simply added after index? How to add a link to the navbar?
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
$menuItems = [
['label' => Yii::t('app', 'Главная'), 'url' => ['/site/index']],
['label' => 'ALANÆ LIFE', 'url' => ['/site/life']], <----------------!!!!!!!!!!!!!!!!!!!!!
['label' => Yii::t('app','FABRIC'), 'url' => ['/site/fabric']],
['label' => 'ALANÆ HOME', 'url' => ['/site/alaniahome']],
['label' => 'АТЕЛЬЕ', 'url' => ['/backend/site/contact']],
['label' => 'ОБ ALANÆ', 'url' => ['@backend']],
['label' => 'ВАКАНСИИ', 'url' => ['/site/contact']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; <----------------!!!!!!!!!!!!!!!!!!!!!
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = '<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Logout (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link']
)
. Html::endForm()
. '</li>';
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
NavBar::end();
?>
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Try using helper Url and its to() and toRoute() methods
I created an alias that leads to the backend
['label' => 'ОБ ALANÆ', 'url' => Yii::getAlias('@backend')],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question