-
Notifications
You must be signed in to change notification settings - Fork 180
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
Navbar depth 1 or displayChildren false #162
Comments
Sorry, I don't fully understand what you want to do. Can you give an example? |
I would like to be able to use ->setDisplayChildren(false) in KnpMenuBundle either by doing it programmatically per menu item or by disabling all of them in Twig. The reason for it, is that my application is very big and I don't want to repeat myself writing more menu's or splitting it up, when I can use the menu structure I have already written once. With the code below I can pull certain parts from my menu structure to sidebars and other places. And it would keep breadcrumbs intact.
I noticed after my post that item.displayChildren is present in bootstrap.html.twig on some parts of dropdowns, but not everywhere to eliminate the html and caret. I have two solutions for this issue and I'll post my results here when I have checked that it is working properly. You can then decide if you want to use it or if it is specific to my needs. |
Ok, this solution works for me - I tried several options. Let me know if there is a smarter way to do it. Replaced line 69 with
Replaced line 120 with
Replaced line 138-139 with
How to use it?
This would remove all html associated with the dropdown and it's children.
If you want to disable all children and not display any of them, you could use the default provided from KnpMenuBundle.
Either way if you disable by extras dropdown false or all children with setDisplayChildren(false), it doesn't show a dropdown caret but a normal link. You can close this issue at will. |
Which version of BootstrapBundle do you use? Are you still on 1.x? |
Oh, sorry I forgot to mention that I am referring to the 2.0 branch. |
I was asking because you used |
Ah, indeed - It seems that I'm fiddling in a old template in my sandbox next to the original. Thanks! |
If i'm not mistaken it missing the the following else if and block of linkElement after LN: 139 ?
|
The original line was 140 was: {%- elseif item.uri is not empty and ((matcher is defined and not matcher.isCurrent(item)) or options.currentAsLink) %} Your line 140 is: {%- elseif item.hasChildren and options.style is defined and options.style in ['tabs', 'pills', 'navbar', 'navbar-right'] and options.currentDepth is sameas(1) and ((item.extras.dropdown is defined and item.extras.dropdown is sameas(false) or item.displayChildren(false) )) %} Since that can't be right I thought it was a copy and paste mistake. Can you take a look at it and fix it? |
Hello,
Is it possible to remove dropdown and caret and treat is as a normal link if I would like to use
{{ knp_menu_render('applicationMenu', {'type': 'navbar', 'depth': 1}) }}
or
{{ knp_menu_render('applicationMenu', {'type': 'navbar', 'displayChildren': false }) }}
The text was updated successfully, but these errors were encountered: