-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for multi-level/sub-navbar? #176
Comments
From my experience, you will either want to create a second menu in wordpress (and functions.php) and add those items to that second menu. If they are a drop down type menu, make sure you extend the depth in your theme file where you are calling the nav_walker: 'depth' => 3, |
WP-Bootstrap-Navwalker respects the choices of the Bootstrap team and is On Thu, Jun 25, 2015, 1:15 PM Jonny Stalnaker notifications@github.com
|
That's sad, it only let you open depth of 2, it would be good if it's at least 3 or show us, how to? |
Hey Ammar, The inability to have 2 level dropdowns is not strictly enforced by the walker. If you set it to a depth of 3 then look at the markup it outputs you will see the 2nd drop down links inside a container. The limitation is imposed by bootstrap and is due to there being no CSS or JS to apply styles or functions on the 2nd dropdown. If you produced the required css and js then I would happily help you modify the walker to output the needed markup but the CSS and JS is outwith the scope of the actual walker. Sent from TypeMail On 15:47, 7 Aug 2015, at 15:47, Ammar Hassan notifications@github.com wrote:
|
Styling would be much easier if a level depth class was added. |
OK so I tested this and discovered that even if all the required markup is output to make a 2nd level dropdown appear (using a slightly modified walker and $depth set to 3 in the call) the main problem is that the Bootstrap JS opens the second dropdown but at the same time closes the first - meaning that although the second is technically open you cannot see it. Anytime you click on anything except the currently ' Someone would need to write a function to override the behavior of Bootstrap in this situation so that it kept the parent dropdown open while the child was opened - but still closed both if someone were co click outside of either the current @steamsynthetic would it be sufficient to add a depth class to only the dropdown container? IE: <li id="menu-item-1331" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-1331 dropdown">
<a title="Top level" href="#" data-toggle="dropdown" class="dropdown-toggle">Top level <span class="caret"></span></a>
<ul role="menu" class=" dropdown-menu depth-1">
<li id="menu-item-1330" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-1330 dropdown">
<a title="second level" href="#" data-toggle="dropdown" class="dropdown-toggle">second level <span class="caret"></span></a>
<ul role="menu" class=" dropdown-menu depth-2">
<li id="menu-item-2501" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-2501">
<a title="third level" href="http://www.domain.com/">PageSpeed Testing Tool</a>
</li>
</ul>
</li>
</ul>
</li> Lines 3 and 6 above have depth classes added |
Yeah. That would work. I was able to solve my issue with this using some CSS My structure is like this: Nav Item <-Top Level In my build, Both sub items for level 2 show side by side, and then the 3rd level stay open underneath. It was for organization for two product titles with their subcategories showing underneath. Sorry for the crass outlines. This image sort of demonstrates what I did. I used a custom class in the wordpress navigation menu to target just this menu item. Its doable, it would just be a lot easier to code into css (im using Sass) if the navigation spat out a depth level to work off of. |
@steamsynthetic I'm going to open a fresh issue for this as what you and I are discussing is not truly a solution to what the OP needs for their specific problem. Also it's completely outwith the scope of the navwalker since we don't enqueue any custom css or js or intend to override Bootstrap in any way and feel that should be mentioned and explained in the opening of a new ticket. |
@pattonwebz just wondering, which depth should i change, as there are a lot of depth variable, and this php seems pretty advance to me |
Hey @mahassan, Sorry for delays in getting back to you, I missed the notification for you commenting last time. The depth variable I mention to change is the one that is passed to the wp_nav_menu() call that is placed in your theme files (not anything directly inside the walker class). It's the one that you can see an example of in the README.md file. |
@pattonwebz Notify aren't working. I had to search for the thread to reply you back. My depth is 3, but it doesn't seem to work at all. Are you sure it is that part and not any other, as i seem in other post. It not spouse to go beyond level 2, as bootstrap in designed. |
@mahassan yeah notify wasn't working for me either for some time. I got the mention notify though. Correct about not supposed to go over 2 (there are some issues when you do) but you can make it work. I'm on mobile just now but once I'm at a proper desktop I'll take another look through here and see how I could help you sort it how you need it to work :) |
@pattonwebz cheers mate. I will look forward to you reply. |
+1 for this please |
+1 |
6 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
Changing this lines on navwalker php code will fixed it for me. sources: Hope this helps |
@azizce In my case work well when I add this option This lines are not necessary CSS cod is good |
The current walker does not support multiple levels of dropdown and neither does Bootstrap core. We may look at adding this in the future but I do not think it will be supported in a BS3 version of the navwalker and as such I am closing this issue for now. There are other threads still open about multi-level support. I encourage you to visit those and express that is what you would like implemented. |
Just in case this helps anyone I got a 3 level menu to work (tested on v4.0.1) by: Changing the depth from 2 to 3 in the call to wp_nav_menu:
and then adding the following jquery (which I adapted from an answer at Bootstrap 4: Multilevel Dropdown Inside Navigation):
and finally positioning using the css (you may want to adjust using a media query to not apply to mobiles):
|
HI there |
I have the same problem. |
Hi There,
I'm a little confused as to how it maps menu items to buttons on the Bootstrap Navbar. I'm attempting to use a sub-navbar like this, but obviously styled and suited to my needs.
However, how I do it to link those additional buttons in the second-level navbar to my menu items? Or is this even possible?
Thanks.
![screen shot 2015-06-11 at 9 26 09 am](https://cloud.githubusercontent.com/assets/4671394/8108035/edb55e5a-101b-11e5-90bf-4314c8c2163d.png)
The text was updated successfully, but these errors were encountered: