Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Comment | File | Size | Author |
---|---|---|---|
#53 | bootstrap_dev-support-menu-block-module-1850194-53.patch | 2.7 KB | ofauravi |
Comments
Comment #1
wundo CreditAttribution: wundo commentedIf you can write a test for this I'd love to commit it ;)
Comment #2
natted CreditAttribution: natted commentedI've just been testing.
In the latest dev, menu block appears to be working as long as "Expand all children of this tree." is not checked under Advanced Options. If that is checked, then bootstrap applies the
.dropdown-submenu
class.I'd have to think about what the best approach would be to play nicely with menu_block and keep the bootstrap style menu's as an option.
In the meantime, in your subtheme, you could always override
bootstrap_menu_link
Comment #3
natted CreditAttribution: natted commentedOk, so I've tested Menu Block and I guess the main issue is that Bootstrap converts all the menu's to dropdowns if they have "Show as expanded" enabled or "Expand all children of this tree".
Some people may not want dropdown menus when using menu block module... am I correct?
I didn't see any other issues but please advise and include as much information as possible if something else with menu_block is broken in relation to bootstrap.
Comment #4
woop_light CreditAttribution: woop_light commented+1
I'm having trouble any time that I have child menu items in a Menu Block. Could you explain how to override bootstrap_menu_link? I'm jumping through hoops trying to get the Bootstrap out of my Menu Block.
Killer job on the Bootstrap theme -- must have been a hell of a job make the two play nice.
woop
Comment #5
woop_light CreditAttribution: woop_light commentedMost importantly, I'm noticing that -- at least in my configuration, might be worth double checking -- when I go to the page of a child link, I cannot go back to its parent's page using the menu. The problem is that it just keeps toggling the dropdown menu.
Comment #6
jorge.aguero CreditAttribution: jorge.aguero commentedDue to the configuration needs for bootstrap dropdown menu, I added a few lines to menu.inc file to accommodate for toggled feature. Currently I am only using it on a per project basis, as this is not the solution for everyone.
Line 62ish
This duplicates the parent that is considered a toggle and places it into the submenu area as the top item with it's own class. The next step is labeling it according to your project needs.
For example adding: Overview or [title] Overview
Comment #7
rowbeast CreditAttribution: rowbeast commentedRe: #3 natted's question about people not wanting dropdown's all the time.
Yes, you're correct. Further I believe this should be independent of the Menu Block module.
It would be great to have that type of functionality toggleable. Perhaps as a theme setting?
"enable bootstrap drop down menus".
I'd also like to second woop_light's question in #4 about how best to override bootstrap_menu_link()?
Could an example be provided on how to approach this so we can do the more traditional indented menu structures?
Great theme, thanks so much for putting the work against it!
~Row
Comment #8
rowbeast CreditAttribution: rowbeast commentedI was able to work out a menu override for my theme based on the original functions in menu.inc. I thought i would post here for those looking to pull the dropdown system out of menu's. I doesn't address the original threads topic so if there is a better place to put it just let me know (not tying to hijack, just help other googlers like myself).
This would go in your subtheme's template.php and you would replace the jetpack_ with your themes name.
If there is a cleaner way to do this, I'd love to see some refactoring.
Comment #9
bigscotia10 CreditAttribution: bigscotia10 commentedNice @rowbeast. Anyone think it would make sense to make menu block menus, select box menu's when on bootsrap mobile? If menu's get 4+ levels deep, any sort of mobile menu gets messy. By making them select boxes, users can scroll and select the menu item quickly.
Comment #10
laroccadahouse CreditAttribution: laroccadahouse commentedi would definitely love to see some menu block compatibility.
Comment #11
laroccadahouse CreditAttribution: laroccadahouse commented#8 works well to show an entire menu block with all children expanded. the functionality i would like to see is the standard menu block with collapsible menu items that show the children of an active page.
I would love to see this switch to a drop down or select list style with all menu items specified in the individual block when it is displayed on a phone.
Comment #12
markhalliwellPretty sure this is a dup of #1893532: [bootstrap][policy][7.x-3.x] Navigation/Menus.
Not sure if there's really a way to target just menu blocks (from a menu tree standpoint). I'm tempted to say that this actually might need to be in a module of some sort. That way we could toggle "dropdowns" on a per menu-block basis, I'd hate to have either "all or none".
Comment #13
Jehu CreditAttribution: Jehu commentedMy quick and dirty solution to use block_menu in sidebar together with the Twitter Bootstrap navbar as main menu (here shown as patch, could be encapsulated as a module or you can overwrite the behavior in your template.php to go a proper way:
Comment #14
acbramley CreditAttribution: acbramley commentedThe main issue with using menu_block with this theme is that if (for example) you have a left hand menu that is set to output from level 2 to unlimited depth, you never get child links rendered because of the explicit condition in bootstrap_menu_link():
It means that no children are output apart from 2nd level.
Comment #15
mstrelan CreditAttribution: mstrelan commentedI'm experiencing the same issue as acbramley in #14.
My workaround is to just call the default theme implementation for menu links in menu blocks.
Comment #16
entrepreneur27 CreditAttribution: entrepreneur27 commentedI am trying to get this functionality and see the code in #15. But I am unclear where to put it. I tried just putting it into my template.php file (in my sub theme) but that was not enough and I suspect I need to call it from somewhere or something. Any tips?
Comment #17
Kiwa CreditAttribution: Kiwa commentedI tried the suggestion in #15 today and it worked for me. I put the code into the template.php of my subtheme as well.
@entrepreneur: Don't forget to replace 'MYTHEME' with your actual theme name and flush caches afterwards, then it should work.
There is a further refinement some might find useful, if they only want to target a specific menu_block:
ID is the ID of the menu block, one can easily read from the URL when editing a particular menu block.
Comment #18
gavmassingham CreditAttribution: gavmassingham commentedAh! Excellent. Thanks mstrelan and kiwa - this has been annoying me for a while.
Comment #19
Eric At NRD CreditAttribution: Eric At NRD commentedThank you so much mstrelan and kiwa! I spent an embarassingly long time trying to figure this out.
Comment #20
entrepreneur27 CreditAttribution: entrepreneur27 commentedOK. I am (stupidly) trying to make this work with 3.1 beta 1. I think this means the code in#15 needs to go somewhere other than the template.php file. I am clearly totally out of my depth.
I post this in the hope of saving someone else some time. Or of anyone knowing what to do to make 3.1 work with menu block and taking pity on me. :)
Comment #21
Schnitzer CreditAttribution: Schnitzer commentedHi, i run in the same issue and this thread inspired me to another solution.
I just wrapped the
if ($element['#below']) { //make some dropdowns }
with a 2nd condition where i only pass my menus wich get dropdowns.
I also set the
['depth'] == 1
to['depth'] >= 1
to get all subitems.In an
else
after this wrapper you can render your normal treestyle.Comment #22
judy07 CreditAttribution: judy07 commentedI'm trying to use Menu Block module with Boostrap 7.x-3.0 and CODE discussion but it does not work
Comment #23
acbramley CreditAttribution: acbramley commentedPlease check comment #14 for an explaination about why it may not be working for you.
Please refrain from posting large blocks of code, especially when they are from the bootstrap theme itself. You can easily reference a file and line number.
In terms of a fix in my case, I managed to get it working by overriding the menu_llnk themeing function in my own theme and removing the depth check from this elseif after copying it from menu-link.fun.php in the bootstrap theme.
Comment #24
modulist CreditAttribution: modulist commentedI used the fix by @mstrelan in #15 and it worked perfectly. I'm still looking forward to trying the ID fix as well in comment #17.
Comment #25
markhalliwellThis is still something I would like to tackle in 7.x-3.x, but definitely by 7.x-4.x.
Comment #26
16am CreditAttribution: 16am commentedI had the same issue with the book navigation using the great Book Outline Block module.
I could fix it by #21 trick, expecially after reading the last 2 line...
Comment #27
doakym CreditAttribution: doakym commented#15 works for me
Comment #28
ckngAnother issue related to menu_block is the FAPI js states not working on admin pages.
Comment #29
Dubs CreditAttribution: Dubs commented#15 works for me too. Can this please be added by default to the bootstrap base theme?
Comment #30
Andy Inman CreditAttribution: Andy Inman commentedJust to offer my code here:
/**
* Book navigation override. Andy, netgenius.co.uk
* This overrides behaviour of the bootstrap theme and reverts to "standard" Drupal behaviour
* for book navigation menu block. Optionally, use dhtml_menu module as well to get animated expand/collapse.
*/
function mytheme_menu_link(array $variables) {
// If this is a book menu sub-item, override it.
if (strncmp($variables['element']['#original_link']['menu_name'], 'book-toc-', 9) == 0) {
return theme_menu_link($variables);
}
// Otherwise hand over to standard bootstrap_menu_link() function.
return bootstrap_menu_link($variables);
}
The above needs to go into your themes template.php or other suitable location. As it says, you can use DHTML menu to get animated expand/collapse. In live use here.
Comment #31
lucass CreditAttribution: lucass commentedI would like to share a simple patch which allow enable submenus with unlimited depth and disable dropdown menus for Menu Block Module.
The setup can be done in settings of bootstrap under the Components tab in "Menu Block Module" menu.
I tested the patch in 7.x-3.0 and 7.x-3.x-dev versions and the result was positive.
Comment #32
bmango CreditAttribution: bmango commentedThe 7.x-3.0 patch in #31 worked well for me. @lucass Thank you very much!
Comment #33
gilsbert CreditAttribution: gilsbert commentedBoth patches are working.
Thanks.
Comment #35
wundo CreditAttribution: wundo at Chuva Inc. commented@lucass, your patch added "tabs as indenting" and trailing white spaces, also there was a typo on the form element description, here is a updated patch which fixes those.
Please notice that I haven't tested the patch, I only fixed those issues I could spot by reading it.
Also, please only submit patches against HEAD, not stable releases.
Cheers,
Fabiano
Comment #36
wundo CreditAttribution: wundo at Chuva Inc. commentedComment #37
markhalliwellI've taken a look at this patch and I'm not very convinced that this is the right approach. It appears that a lot of what this code is doing is "unsetting" previous functionality in an effort to fix a specific use case (and to perhaps address the issues outlined in the related issue I'm posting now). We shouldn't get in the habit of hacking our own code if we can avoid it (which is what the other related issue is about).
In all reality, the code attached is not actually specifically targeting the menu block module at all (which is what this issue should be about). Instead, it is rather generic and is, in fact, obscuring global menu management under the guise of "supporting" a specific module.
Furthermore, I don't think this issue should introduce new settings, but rather do what the issue title suggests: "[add] support [for] menu block module" which any code logic applied here should be inherent and automatic based simply on if the module is installed. So, I'm updating the title and component to reflect this and make it a little more explicit.
I would also say that this issue should probably be postponed on the related issue (and perhaps even moved to 7.x-4.x) as we have other issues that need focus at the moment. However, in the interest of progress, I'll just leave this issue on 7.x-3.x and set to CNW.
Comment #38
acbramley CreditAttribution: acbramley commentedGotta agree with @markcarver here. At least the work done previously highlights what kind of thing fixes it for menu_block and hopefully that'll facilitate an easier "real" fix :)
Comment #39
lucass CreditAttribution: lucass commentedI guess that the patch hit the issue, the options of enable deeper levels and to disable dropdown menus are features that support the Menu Block Module and allow this to work correctly.
About the UI settings, why don't introduce? This makes more customizable and allow the control of behavior according to which the users need, so who want the original behavior of Bootstrap simply dont enable nothing, moreover the standard is the options disabled.
If this is not the right approach, so what is? I would be glad to know in order to help.
Comment #40
gilsbert CreditAttribution: gilsbert commentedHello everyone.
I'm not a maintainer of bootstrap but I would like just to contribute with a few thoughts.
Personally I like (and I prefer) changes introduced by UI options instead of changes introduced on theme/module's behavior. This approach should avoid a lot of discussion about what is necessary, what is the original purpose, what is mandatory, and so on. It also avoid conflict with people who need the original behavior unchanged. That said I would suggest to keep the changes by UI options instead to give bootstrap a new menu behavior.
I agree with @lucass about the two new options: both are directly necessary for a complete integration between bootstrap theme and menu block module. Yes it is a generic approach but it should bring more credit to the patch (not less).
@wundo: thank you for your effort. I agree that a patch for the stable version is not mandatory but some people may be thankful for not being mandatory to use a dev version (less stable right?) only because they need one or both new options. For example we are using bootstrap in all our production sites and it is good to have this patch avaliable.
This issue has almost 3 years old. I would like to ask to keep it for the next release and say thanks for @markcarver for allowing us to help.
Regards,
Gilsberty
Comment #41
markhalliwellHm. I will attempt to reiterate what I said, but hopefully in a way that will make more sense:
Comment #42
gilsbert CreditAttribution: gilsbert commentedHi @markcarver.
Good idea. I'm sure that adding those two new options in general tab will bring us an excellent result.
Should @lucass go for it? Should a new topic be created at general tab? What about "Menu behavior"?
Regards,
Gilsberty
Comment #43
noman_297 CreditAttribution: noman_297 commentedI have an issue with book explorer navigation with bootstrap theme,Parent link is not clickable also the expandable links not working with book explorer navigation.Also +,- icon is not working.Plz help me out.
Comment #44
lucass CreditAttribution: lucass commentedHello @markcarver,
There a possibility to incorporate the features, deeper level menu and disable dropdown menu, in bootstrap theme ?
If yes, as you think it should be done?
I will be at the disposal to help making this features.
Best.
Comment #45
drupbasic CreditAttribution: drupbasic commented#15 worked for me (copy/paste to the top of my subtheme). All childs are shown in the block. But, my hierarchy is flattened out. Any solutions?
Comment #46
markhalliwellThe above patches are not the right approach. Something like #15 is, in fact more in line with what I had envisioned. That being said, this issue really isn't a priority right now.
Comment #47
gilsbert CreditAttribution: gilsbert commentedWhy postpone when you have people interested to help?
Thank you anyway.
Comment #48
dadderley CreditAttribution: dadderley as a volunteer commentedThank you mstrelan for the solution in #15.
Comment #49
tcowin CreditAttribution: tcowin commentedThe issue isn't so minor for those of us needing to display more than the second menu level -- the patch by @lucass, @wundo in #35 works well for me, although it would be good to be able to treat main nav and other nav areas independently.
Comment #50
metakel CreditAttribution: metakel commentedMy way to deal with the issue is to remove the class "dropdown-menu" from the secondary UL at the menu tree. I do this by adding the below function to the theme's
template.php
(replace the "XYZ" with the name of the menu that you wish to disable dropdown):Then clear the cache and reload.
Comment #51
markhalliwellI don't think this is going to happen for 7.x-3.x.
Comment #52
stavroch CreditAttribution: stavroch commentedAny news?
I have the same issue. The main-menu display only the 2nd level menu.
The third level menu doesn't displayed.
Comment #53
ofauravi CreditAttribution: ofauravi commentedI have adapted patch #31 to work on later versions.