V
V
Vladislav2020-02-10 20:22:06
Yii
Vladislav, 2020-02-10 20:22:06

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();

There is such a standard code in Yii2, I need to add a dropdown menu to this menu. and move the input button to the right side. I read the documentation and did not understand anything there, because there is nothing like in this example. And I wanted to shift to the right by adding 'class'=>'pull-right' does not work. I've already tried everything, help plz __)))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2020-02-10
@cr1gger

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.

M
Maxim Timofeev, 2020-02-11
@webinar

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 question

Ask a Question

731 491 924 answers to any question