H
H
hollanditkzn2017-05-16 15:18:02
Yii
hollanditkzn, 2017-05-16 15:18:02

How to add counter to nav?

I need to set the number of new notifications in navbar. I have an empty counter with this approach. or as I understand it is necessary to drive into a variable and then display everything or not?

<?php
    NavBar::begin([
        'brandLabel' => 'Holland',
        'brandUrl' => ['/zakaz/index'],
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
if (!Yii::$app->user->isGuest) {
        $menuItems[] = ['encode' => false, 'label' => '<span class="glyphicon glyphicon-bell" style="font-size:21px"></span><span class="badge">.$count'.$count, 'options' => ['id' => 'notification']];
    }
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

1 answer(s)
M
Maxim Fedorov, 2017-05-16
@hollanditkzn

or as I understand it is necessary to drive into a variable and then display everything or not?

you need to drive information into count

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question