Answer the question
In order to leave comments, you need to log in
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'
],
]);
?>
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question