S
S
Skrolea2016-04-28 19:08:45
Yii
Skrolea, 2016-04-28 19:08:45

How to disable navbar-toggle?

Good afternoon. I would like to disable the button that the standard Navbar widget generates. Found that there is a method renderToggleButton(). But how to use it?

<?php
                NavBar::begin([
                    'brandLabel' => FALSE,
                    'brandUrl' => Yii::$app->homeUrl,
                    'options' => [
                        'class' => 'navbar navbar-default navbar-fixed-top',
                        'id' => 'mainNav',
                        'renderToggleButton' => 'false'
                    ],
                ]);
                ?>

Where to stick it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2016-04-28
@Skrolea

If we are talking about standard yii2-app-basic or advanced, then you can find it in app/frontend/views/layouts/main.php folder for advanced or app/views/layouts/main.php for basic. NavBar is initialized there, and changes should be made there.
upd:
To make changes to the widget itself, you can add the CustomNavBar extends yii\bootstrap\NavBar class to the widgets folder, and... the simplest solution is to override the renderToggleButton function;
renderToggleButton() {return ''}
and in layouts/main.php instead of use yii\bootstrap\NavBar; write use app\widgets\CustomNavBar;
Because in the standard NavBar bootstrap, the renderToggleButton() function is executed regardless of options and cannot be disabled by the settings array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question