Z
Z
zeaovede2021-06-30 14:57:12
Yii
zeaovede, 2021-06-30 14:57:12

How to make a drop down menu in yii2?

What edits need to be made to the current code to get the yii2 dropdown menu?

<div class="menu-line">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="pull-left main-menu">
                    <?php
                    echo SiteNav::widget([
                        'options' => ['class' => ''],
                        'encodeLabels' => false,
                        'items' => [
                            ['label' => '<span class="ar_left"></span>Главная<span class="ar_right"></span>', 'url' => ['/site/index'], 'options'=>['class' => 'hidden-xs']],
                            ['label' => '<span class="ar_left"></span>Цены<span class="ar_right"></span>', 'url' => ['/site/boost']],
                           // ['label' => '<span class="ar_left"></span>Дуо бустинг<span class="ar_right"></span>', 'url' => ['/site/duoqueue'], 'options'=>['class' => 'hidden-xs']],
                           // ['label' => '<span class="ar_left"></span>Coaching<span class="ar_right"></span>', 'url' => ['/site/coaching'], 'options'=>['class' => 'hidden-xs']],
                            //['label' => '<span class="ar_left"></span>Blog<span class="ar_right"></span>', 'url' => ['/site/works'], 'options'=>['class' => 'hidden-xs']],
                            ['label' => '<span class="ar_left"></span>Помощь<span class="ar_right"></span>', 'url' => ['/site/faq'], 'options'=>['class' => 'hidden-xs']],
                            ['label' => '<span class="ar_left"></span>Быстрый заказ<span class="ar_right"></span>', 'url' => ['/site/custom'], 'options'=>['class' => 'hidden-xs']],
                        ],
                    ]);
                    ?>
                    </div>
                    <div class="right-menu pull-right">
                    <?php
                    if (User::hasRole(['Admin'], true)) $url = ['/manager/index'];
                    else if (User::hasRole(['Booster'], false)) $url = ['/booster/index'];
                    else $url = ['/account/index'];
                    echo SiteNav::widget([
                        'options' => [
                            'class' => 'pull-right',
                            'id' => Yii::$app->user->isGuest ? 'no-login':'auth-user',
                        ],
                        'encodeLabels' => false,
                        'items' => Yii::$app->user->isGuest ?
                            [
                                ['label' => '<span class="ar_left"></span>Войти<span class="ar_right"></span>', 'url' => ['/site/login'], 'options' => ['class' => 'link-login'],/*'javascript:clickLogin()'*/],
                            ]
                            :
                            [
                                ['label' => '<span class="ar_left"></span>Мой аккаунт<span class="ar_center"></span>', 'url' => $url],
                                ['label' => 'Выйти<span class="ar_right"></span>', 'url' => '/logout'],
                            ]
                        ,
                    ]);
                    ?>
                    </div>
                </div>
            </div>
        </div>
    </div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question