S
S
Silverviql2018-05-23 11:31:35
Yii
Silverviql, 2018-05-23 11:31:35

How to wrap the buttons of the Nav widget in the mobile version into one button?

In the Nav::widget widget, buttons are drawn with the priorities of which user sees these buttons.
How to wrap buttons into one button like in bootstrap

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

public function run()
    {
        return Nav::widget([
        'options' => ['class' => 'nav nav-pills headerNav'],
        'items' => [
         ['label' => 'Партнеры', 'url' => ['partners/index'], 'visible' => Yii::$app->user->can('admin')],
            ['label' => 'Аналитика', 'url' => ['site/analytics'], 'visible' => Yii::$app->user->can('admin')],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-05-23
@slo_nik

Good afternoon.
Approximately so (the code may be with errors, fix it yourself)

'items' => array_filter([
  Yii::$app->user->can('admin') ? ['label' => 'Партнёры'] : false, 
 Yii::$app->user->can('user') ? ['label' => 'Аналитика'] : false, 
])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question