Answer the question
In order to leave comments, you need to log in
Yii2 Bootstrap site navigation?
<?php
NavBar::begin([
'brandLabel' => 'АНРБ',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-default',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav'],
'items' => [
['label' => 'Главная страница', 'url' => ['/site/index']],
['label' => 'Меню сайта1', 'url' => ['/site/index1'] ],
['label' => 'Меню сайта2', 'url' => ['/site/index2']],
['label' => 'Меню сайта3', 'url' => ['/site/index3']],
['label' => 'Не главная ', 'url' => ['/site/about']],
['label' => 'Обои', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ? (
['label' => 'Войти', 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
'Выход (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
)
],
]);
NavBar::end();
Answer the question
In order to leave comments, you need to log in
It’s faster for you to simply insert the layout from Bootstrap and not worry. If you are so tormented with this, then what will happen if you need to somehow make a menu around everything?
There is no difference from using the widget here.
Yii widgets for Bootstrap are a lot of fun. If there are a lot of edits, it's better to immediately demolish and write your own widget or just html. There, a step to the left, a step to the right - execution. They did it for show, only for standard solutions.
Ideally, we make our own (perhaps we inherit from the yuish one), redefine what we need, enjoy life.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question