Answer the question
In order to leave comments, you need to log in
How to create a multi-level menu or list in Bootstrap?
Good afternoon. Is it possible using Nav to create such a menu?
It is more like a multi-level list. Maybe some other component. It would be very good if there was a ready-made component within Yii2, so as not to draw it yourself. Because I think the task is standard, but I did not find information in the bootstrap documentation
https://github.com/leandrogehlen/yii2-treegrid similar functionality, I use it to edit menu items.
Answer the question
In order to leave comments, you need to log in
Why don't you like yii\widgets\Menu?
www.yiiframework.com/doc-2.0/yii-widgets-menu.html
And the same nav is not limited to one level.
Good afternoon.
It is enough to look into the documentation and the need to write a question disappears immediately.
Nav(items)
PS And there, at the link I gave, at the very beginning of the page, an example.
Read the documentation, don't be lazy!
echo Nav::widget([
'items' => [
[
'label' => 'Home',
'url' => ['site/index'],
'linkOptions' => [...],
],
[
'label' => 'Dropdown',
'items' => [
['label' => 'Level 1 - Dropdown A', 'url' => '#'],
'<li class="divider"></li>',
'<li class="dropdown-header">Dropdown Header</li>',
['label' => 'Level 1 - Dropdown B', 'url' => '#'],
],
],
[
'label' => 'Login',
'url' => ['site/login'],
'visible' => Yii::$app->user->isGuest
],
],
'options' => ['class' =>'nav-pills'], // set this to nav-tab to get tab-styled navigation
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question