How can I extend the functionality to include the parent item in the menu?
If my Primary Links menu is
-Foo1
--Bar1
--Bar2
etc. then setting the menu to Primary Links, the item to < root of Primary links > and starting level to 2 then when I go to Foo1 the menu is
Bar1
Bar2
when I'd like
Foo1
Bar1
Bar2
This seems to be the way the Druaplcon site works at http://paris2009.drupalcon.org/aboutus - do I have to manually add in an entry for Foo1 to the menu so it's
-Foo1
--Foo1
--Bar1
--Bar2
or is there a better way?
Comment | File | Size | Author |
---|---|---|---|
#134 | 476798-134.patch | 4.57 KB | komalk |
| |||
#130 | menu_block-include_parent_8x-476798_130.patch | 4.42 KB | Albert Volkman |
#128 | menu_block-include_parent_8x-476798_3.patch | 4.35 KB | glass.dimly |
#127 | menu_block-include_parent_8x-476798_2.patch | 4.27 KB | glass.dimly |
#125 | menu_block-include_parent_8x-476798.patch | 4.26 KB | glass.dimly |
Comments
Comment #1
hefox CreditAttribution: hefox commentedI couldn't see any way to do that either without setting the block title, which I see as error prone.
Attached is a patch with my solution
Cool module
Comment #2
marcushenningsen CreditAttribution: marcushenningsen commentedSorry for the newbie question: To which file is the patch supposed to be applied?
Comment #3
cvaughn13 CreditAttribution: cvaughn13 commentedhefox,
I tried to implement your patch, but could not get it to work. Instead,
when at
Parent
of
Parent
--Child1
--Child2
all I saw was
--Child1
--Child2
Is there a setting that needs to be set so that only
Parent
--Child1
--Child2
can be seen? I don't want to see all the other Parent links, jut the Parent link that is active, and its children in a sidebar.
Thanks for your help.
Comment #4
snorkers CreditAttribution: snorkers commentedI got this patch to work fine (rolled against the current release 6.x-2.2), although needed to check the
Expand children: > Expand all the sub-menus of this tree
option to get it to work as planned; I also set starting level to '1st with parent' (which is the option the patch adds) and Maximum depth to 2.This is a really useful addition to menu block and I have suggested that this code should be reviewed. Hopefully this functionality will make it into a future release of the module.
Thanks @hefox
Comment #5
abelb CreditAttribution: abelb commentedThanks @hefox
i got this to work perfectly for one of my menus. exactly what i was looking for.
it would be great to be able to choose 2nd level with parent!
anyone know how to do that?
Comment #6
cvaughn13 CreditAttribution: cvaughn13 commentedhefox, et. al,
The patch does work, sorry for the confusion. Though, I did misinterpret what I though the patch was going to do.
I am looking for what alburton I think is suggesting by "2nd level with parent."
That is, show a second level link and only the parent it is connected to, not all the other menu items at the parent's level.
For example
If I click on Parent1 (or any of its children), I see:
Parent1
--child1
--child2
--child3
and not
Parent1
--child1
--child2
--child3
Parent2
Parent3
Parent4
Comment #7
GuillaumeDuveauMaybe you could use the cool new features in -dev : #345419: Add option for menu title as link.
Since John committed the solution above, I don't think patches in that issue could be committed.
Comment #8
Danny Englandersubscribing
edit: the patch worked for me, this is exactly what I needed. It messed with my CSS a little but that can be fixed.
The other thing I just learned about is to use the command line to apply the patch, in my case Terminal in OS X. I took the patch and put it in the same directory as the files to be patched and then used the command:
patch -b < menu_block_show_parent.patch
This saves lots of time. If your site is online and you don't have ssh access you could download the folder with the module to be patched via FTP, make a temp folder on your hard drive and then do the patching and reupload.
Comment #9
snorkers CreditAttribution: snorkers commentedJust hacked around and re-rolled the patch for 6.x-2.3 (#1 won't work against he latest release). Uses the same code that @hefox worked out and seems to work fine...
I'm not a great patch roller... so it's 2 separate files. (off topic: can the text from 2 sep patches just be merged to create a single file?)
Comment #10
hefox CreditAttribution: hefox commented(@snorkeys, yes I've done it a few times (combine patches) XP.
Comment #11
jtidal CreditAttribution: jtidal commentedFor me, this patch breaks menu items more than 2 levels deep. If I include the parent, the block doesn't show up at all.
Any fixes?
Comment #12
FreddieK CreditAttribution: FreddieK commentedThe patch didn't work for me, and a good solution should be to make an 'add parent to menu links' checkbox available on all levels, not just first.
Comment #13
garryi CreditAttribution: garryi commentedHas there been any progress with this? This seems to be the right direction, but the patch in #9 is not working (for me at least).
Comment #14
jim22 CreditAttribution: jim22 commentedThis would be a great feature.
Comment #15
stockliasteroid CreditAttribution: stockliasteroid commentedHere's a patch against 2.3. Instead of the arbitrary depth limit of 1 in the previous patch, this should support unlimited depth below the parent menu item using the existing level selection dropdown. It just provides a checkbox on the block settings called "Include Parent"...
Comment #16
hefox CreditAttribution: hefox commentedsetting it to needs review
Comment #17
christiaanb CreditAttribution: christiaanb commentedI've modified stockliasteroids patch a bit to also work for sub menu blocks that don't have a parent menu item selected but only a menu.
Comment #18
knalstaaf CreditAttribution: knalstaaf commentedBelieve it or not, but all it took was highrockmedia's reply to start patching for the first time. Other tutorial pages seemed a little overwhelming to me.
Thank you, highrockmedia, for this valuable entry.
Comment #19
knalstaaf CreditAttribution: knalstaaf commentedJust what I was looking for - thanks. This option should be available by default.
Comment #20
Ronino CreditAttribution: Ronino commentedI ported the patch provided in comment #17 (thank you!) to Drupal 7 including some minor improvement, see #1045352: Including parent item in the menu
Comment #21
robcarrI've just rolled the patch at #17 against 6.x-2.4 and works (with a few offsets). The patch certainly works, and it seems that there are at least 2 others that have tested it => RTBC.
Comment #22
dgsiegel CreditAttribution: dgsiegel commentedi can confirm that the patch is working with 6.x-2.4.
attached you can find a re-roll of the patch in #17 which just removes the offset warnings.
Comment #23
safetypinI've manually applied the patch from #22 to 7.x version files, and everything seems to be functioning as expected.
Comment #24
robcarrNice to see that it works in 7.x. But was the 6.x-2.4 patch committed? If not can it be left at RTBC and a separate issue for D7 started?
Comment #25
Ronino CreditAttribution: Ronino commentedSome time ago, I adapted the patch from comment #17 for D7 with some minor additions (work for menus of arbitrary levels and do not add the parent item as the only item in the menu), see #1045352: Including parent item in the menu. I was asked to to post the patch here, so this is what I do.
Comment #26
mmcintosh CreditAttribution: mmcintosh commentedJust tried this patch and it fails test -- menu_block version info listed below as is the fail
Any ideas ??
Thanks
patching file b/sites/all/modules/menu_block/menu_block.admin.inc
Hunk #1 FAILED at 246.
Hunk #2 FAILED at 356.
2 out of 2 hunks FAILED -- saving rejects to file b/sites/all/modules/menu_block/menu_block.admin.inc.rej
patching file b/sites/all/modules/menu_block/menu_block.module
Hunk #1 FAILED at 180.
Hunk #2 FAILED at 196.
Hunk #3 FAILED at 317.
Hunk #4 FAILED at 505.
Hunk #5 FAILED at 516.
Hunk #6 FAILED at 538.
6 out of 6 hunks FAILED -- saving rejects to file b/sites/all/modules/menu_block/menu_block.module.rej
menu_block version:
Project : menu_block
Type : module
Title : Menu Block
Description : Provides configurable blocks of menu items.
Version : 6.x-2.4
Package : Other
Core : 6.x
PHP : 4.3.5
Status : enabled
Path : sites/all/modules/menu_block
Schema version : 6201
Requires : block, menu
Required by : none
Comment #27
FreddieK CreditAttribution: FreddieK commentedWorks like a charm!
Comment #28
mmcintosh CreditAttribution: mmcintosh commentedI reattempted patch and it worked fine this time.
Regards
Mark
Comment #29
mjpg CreditAttribution: mjpg commentedDoes anyone have a patched version of the D7 menu block module that I can use?
menu_block_include_parent_d7.patch
as I am not able to apply the patch easily myself.
Thanks
Comment #30
Ronino CreditAttribution: Ronino commentedmjpg, attached you find the 7.x-2.2 version, patched with my patch from comment #25
Comment #31
mjpg CreditAttribution: mjpg commentedMany thanks - still not quite working but I suspect that it may be the dual language versions of the pages with two menu entries causing an issue.
Comment #32
rbishop CreditAttribution: rbishop commentedthank you for this patch! working great.
Comment #33
Yuri CreditAttribution: Yuri commentedfor #30 to work, I had to set the maximum depth to 2 or more (i had it on 1) otherwise you only see the parent item.
Comment #34
knalstaaf CreditAttribution: knalstaaf commentedIndeed Yuri, the maximum depth should be set to "2", which leads to the menu being built up in a list within a list.
Is there a way this behaviour doesn't occur? In other words: is it possible to add both the parent item and the subitems in one list?
Here's what I mean:
Currently this is the case:
Here's what I'd prefer:
If this isn't possible or if it's bad practice (confusing for SEO), then it's still possible to solve that through CSS layout-wise.
Comment #35
mlecha CreditAttribution: mlecha commentedDue to issues from the Drupal 7.12 upgrade it seems that we're forced to upgrade to Menu Block 2.3.
#1425342 Drupal core upgrade from 7.10 to 7.12 causes menu block to fail
I was happily using Ronino's patch at #25
I'm not sure if the Menu Block 2.2 patch will work on Menu Block 2.3?
It would be so great to get the "Include parent" functionality included in Menu Block that this patch provides.
Comment #36
rbishop CreditAttribution: rbishop commentedi re-applied Ronion's patch at #25 to Menu Block 2.3 post drupal 7.12 upgrade and all appear to work as expected for me
Comment #37
iknowbryan CreditAttribution: iknowbryan commentedMenus disappear when you set the "Fixed parent item" to something more than one level deep
(If I start one level deep things are fine)
I'm on drupal 7.12 and menu_block 2.3 and have applied the #25 patch without errors
Any ideas??
e.g. of what I'm after
PARENT ITEM
- PARENT ITEM TWO
-- PARENT ITEM THREE ( I want to start here)
-- ITEM
-- ITEM
-- ITEM
-- ITEM
I'd like to create a menu block that looks like
-- PARENT ITEM THREE
-- ITEM
-- ITEM
-- ITEM
-- ITEM
Comment #38
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm on drupal 7.14 w/ menu_block 2.3 and the patch from #25 seems to work perfectly for me.
Looks like this issue has been going on for a while - any way we can get this feature into a release? Is there anything blocking its inclusion?
Comment #39
alexverb CreditAttribution: alexverb commentedI'm on 7.15 and Menu Block 2.3 and also confirm this patch is working great for me. It would be nice indeed to have this feature in the future release.
Comment #40
hkirsman CreditAttribution: hkirsman commentedPatch #25 worked for me (using 2.3). This should be included in the module!
Comment #41
Matthew OMalley CreditAttribution: Matthew OMalley commented+1 please approve and release
Comment #42
rylowry@gmail.com CreditAttribution: rylowry@gmail.com commented#25 worked for me using menu_block 7.x-2.3.
Comment #43
Katy J CreditAttribution: Katy J commentedThank you. Patch in #25 worked perfectly for me with 7.x-2.3 once I remembered how to apply a patch using the cmd line rather than cut and paste!
Comment #44
hkirsman CreditAttribution: hkirsman commentedWill this be included into the module?
Comment #45
gmclelland CreditAttribution: gmclelland commentedHow is everyone applying this patch from #25?
I have tried many different variations:
patch < menu_block_include_parent_d7_0.patch
patch -p1 < menu_block_include_parent_d7_0.patch
patch -p0 < menu_block_include_parent_d7_0.patch
git apply -v menu_block_include_parent_d7_0.patch
Nothing seems to work
Comment #46
Ronino CreditAttribution: Ronino commentedgmclelland, from what directory did you try to apply the patch?
Comment #47
gmclelland CreditAttribution: gmclelland commented@Ronino - Thanks for the reply. I tried running those commands from the root of the module.
Here is a untested manual reroll of #25 that should apply against MB 2.3.
Hope it helps someone.
Comment #48
othermachines CreditAttribution: othermachines commentedHere's a new patch rerolled against 7.x-2.x-dev and tested on Drupal 7.23.
Anyone who (like me) is eager to have this feature committed should install 7.x-2.x-dev, test this patch and report back. It's a good feature.
Re comment #37 - also tested on a menu block starting on third leve; works fine.
Thanks everyone.
Comment #49
othermachines CreditAttribution: othermachines commentedComment #50
tchopshop CreditAttribution: tchopshop commentedAfter patching this I am getting this Notice:
Notice: Undefined index: include_parent in menu_tree_block_data() (line 284 of /profiles/panopoly/modules/contrib/menu_block/menu_block.module).
Comment #51
othermachines CreditAttribution: othermachines commented@tchopshop
Sounds like it may not have applied properly to menu_block.admin.inc. Which patch and which version of menu_block?
Comment #52
tchopshop CreditAttribution: tchopshop commentedthe patch from #48 and the current dev. I applied the patch manually.
Comment #53
othermachines CreditAttribution: othermachines commented@tchopshop -
If you've applied the patch manually, it's difficult for me to troubleshoot. As you can see from the error, $config['include_parent'] is undefined. If the patch was applied properly, this index should be defined in the function menu_block_get_config(). The only other thing I might suggest is that, if you already have a menu block defined, then you may need to resave your block configuration. Let us know if you make any progress.
Comment #54
caschbre CreditAttribution: caschbre commentedWe're running into the same issue as #37. If our parent is at the top of the menu then it works great. However it our parent (as designated in the menu block config) has a parent menu item of it's own, then it returns nothing.
The issue seems to be stemming from the logic inside menu_tree_prune_tree...
If I were to comment out the if condition and just use...
$tree = $tree[$key]['below'] ? $tree[$key]['below'] : array();
... the menu block renders a menu, though without the parent. It's when we reset the $tree to the parent item instead of the children ('below') that the logic check of
if ($tree[$key]['link']['mlid'] == $plid) {
fails and we eventually hit the !$found_active_trail condition which wipes out any results.
I'm still debugging to figure out why... but i've narrowed it down to that part of the patch that seems to be the cause of the issue.
Comment #55
caschbre CreditAttribution: caschbre commentedAttached is a new patch which is just a small modification to the patch in #48. I've tested this against 7.x-2.x and 7.x-2.3 locally. I did have to manually apply the patch to 7.x-2.3.
Difference between the two patches is small...
#48: if (!empty($include_parent)) {
#55: if (!empty($include_parent) && $plid != $parent_item['plid']) {
This solved the issue we were experiencing noted in comment #37 above.
Comment #56
othermachines CreditAttribution: othermachines commentedBrilliant. The patch is good and solves the problem described in #54.
I SO want to mark this as reviewed and tested but I suppose we should wait for one or two others to chime in.
Thanks, @caschbre!
Comment #57
wooody CreditAttribution: wooody commentedComment #58
wooody CreditAttribution: wooody commentedComment #59
wooody CreditAttribution: wooody commentedHi,
How can I make the same with Better Jump Menus module...
https://drupal.org/project/jump_menu
Thanks..
Comment #60
othermachines CreditAttribution: othermachines commented@wooody
Go to the Better Jump Menus issue queue and post your question there.
Comment #61
4kant CreditAttribution: 4kant commentedHi there,
I needed a special background color for a menu block when it´s parent item is active (li.active-trail).
With the patch from #55 I could do that.
In CSS i had to set diplay:none for the parent li-item and for it´s sub-items I set diplay:block.
But with the presence of the selector "li.active-trail" of the parent item, I can now style the block.
Thanks!
Comment #62
othermachines CreditAttribution: othermachines commentedThanks @4kant. I think this qualifies as reviewed and tested. I checked and no re-roll is required.
Comment #63
jessehsThe patch in #55 is working for me. It does not apply against 2.3, but it does apply against Dev. (I tested against revision 8dd19f03.)
Comment #64
phai CreditAttribution: phai commentedThe patch #55 is working for me too (REMEMBER: it applies only on DEV).
Thanks
Comment #65
ZenDoodles CreditAttribution: ZenDoodles commentedThis patch works for me. Testing in a fresh install, using the following steps:
A couple of minor code comments:
This also needs to be updated in hook_menu_block_blocks() in menu_block.api.php
Sorry this is so nitpicky... We prefer closing braces on their own lines.
@see https://drupal.org/coding-standards
Here too. (Still nitpicky)
Comment #66
othermachines CreditAttribution: othermachines commentedNothing wrong with nitpicky. Here's another go.
Comment #67
phai CreditAttribution: phai commentedEhmmm.... but it's just a my theory... or updating module to 7.x-2.4 (released today) this behaviour is still unfixed?
Comment #68
othermachines CreditAttribution: othermachines commentedDarn. Yeah, looks that way.
Comment #69
jackhutton CreditAttribution: jackhutton commentedjust updating to 7.x-2.4 and notice there's no toggle to 'show parent'.
I reran the patch in #66 which brought back my parent item onto the menu blocks
Comment #70
othermachines CreditAttribution: othermachines commented@jackhutton - If you apply a patch, you have to keep applying it with every update until the patch is committed.
Comment #71
janchojnacki CreditAttribution: janchojnacki commentedThanks for the patch, othermachines
There is part to remove the only item from the tree if it is the parent item configured to be included. But in my case it was needed to include the only item in the tree, so I a bit extended your patch to make removal of the only item optional.
Comment #72
brad.bulger CreditAttribution: brad.bulger commentedthis is a reroll of the patch from #66 against the current 2.x branch. i didn't include the extra feature from #71 only because i haven't used it.
Comment #73
othermachines CreditAttribution: othermachines commentedRe-rolled patch in #72 tests OK and applies cleanly. I think it's ready to commit. Thanks @brad.bulger.
@janchojnacki - Please apply the patch in #72 to latest -dev, then create a new patch with only your changes. Post it as a separate issue and indicate that it is dependent on #72 patch being applied/committed first. Thanks!
Comment #74
PolThis patch is working perfectly on 7.x-2.x. Can't wait to see this in.
Comment #75
othermachines CreditAttribution: othermachines commented@janchojnacki - Might be a good fit for your patch? Issue #2368805: Show always fixed parent item
Comment #76
caxy4 CreditAttribution: caxy4 commented+1 for getting this included in 7.x-2.x. Please include ASAP!!!
Comment #77
perlgal CreditAttribution: perlgal commentedHi
I applied the patch in #72 against the latest dev version and it works, but I have the same issue as mentioned in #37 and then revisited in #55 with a patch, that does not work on the latest dev with patch in #72.
Any suggestions will be helpful.
Thanks!
Comment #78
othermachines CreditAttribution: othermachines commentedHi, @perlgal.
Can you be more explicit about your problem so that we can try to reproduce? I've confirmed that the fix introduced in #55 is included in #72 patch.
Please include your menu block settings.
Comment #79
perlgal CreditAttribution: perlgal commented@othermachines Thank you for the quick reply!
Menu block for Submenu B
The starting level is 1st level primary
Include parent is checked.
Maximum Depth - Unlimited
Expand all children of this tree is checked.
Fixed parent item is
Works for
-Primary Item A
--Submenu B -> Works for submenu B
Does not work for
-Primary Item A
--Sub Menu A2
---Sub Menu B (under A2) -> Does not work. No menu displayed at all.
I hope this explains my issue. Thank you!
Comment #80
othermachines CreditAttribution: othermachines commented@perlgal - It helps, thanks! To clarify, in both examples "Submenu B" is the fixed parent item?
Comment #81
perlgal CreditAttribution: perlgal commentedYes. Submenu B is the fixed parent item.
Comment #82
othermachines CreditAttribution: othermachines commentedThanks for catching that, @perlgal. I was able to reproduce the problem with your settings.
Comment #83
othermachines CreditAttribution: othermachines commentedSo here's the problem...
When iterating over a fixed item's ancestors (p1, p2, p3...), if the fixed item starts at level 3 (or greater) it will always pass this condition on first iteration:
This is because the fixed item's immediate parent will never be equal to its first ancestor ('p1').
So if our tree looks like this:
1.1 <-- p1
.. 2.1 <-- p2
.. .. 3.1 <-- fixed item
.. .. .. 4.1
.. .. .. 4.2
The fixed item's immediate parent is 2.1. Let's iterate through its ancestors...
1.1 <-- p1
This doesn't match fixed item's immediate parent, so start the tree here. Wrong, wrong, wrong. Next iteration...
.. 2.1 <-- p2
It matches! But damn, already too late. We've messed up the trail. And what happens when we mess up the trail?
Yep, that means no menu.
I ran out of time to implement a fix, but maybe someone else will get to it before I do.
Comment #84
othermachines CreditAttribution: othermachines commentedThis patch also checks against the depth of the fixed item.
Comment #85
Melissamcewen CreditAttribution: Melissamcewen commentedPatch from #84 works great for me
Comment #86
darvanen#84 works for me, even when applied to current stable version (7.x-2.6)
Comment #87
perlgal CreditAttribution: perlgal commentedThank you, @othermachines! The patch from #84 works on 7.x-2.6
Comment #88
othermachines CreditAttribution: othermachines commentedThanks everyone. I've retested against latest -dev. I wouldn't mind one more tester before marking RTBC.
Comment #89
bendev CreditAttribution: bendev commentedJust tested it and could make it work withtout any issue...
thanks
Comment #97
othermachines CreditAttribution: othermachines commentedThat was weird. The actual last submitted patch still passes.
Comment #98
dureaghin CreditAttribution: dureaghin commentedThe patch from #84 not working on 7.x-2.7.
Notice: Undefined index: include_parent in menu_block_configure_form() (line 317 of /sites/all/modules/contrib/menu_block/menu_block.admin.inc).
Comment #99
othermachines CreditAttribution: othermachines commented@Hakintosh - This should really be applied against 7.x-2.x-dev but I did apply it against 7.x-2.7 with no issues. Did your menu_block.module file get patched? The only way the notice makes sense to me is if
menu_block_default_config()
didn't get updated to include the 'include_parent' key.Comment #100
rkent_87 CreditAttribution: rkent_87 commented#84 works for me on 7.x-2.x-dev albeit with whitespace warnings when applying the patch
Edit: Actually, does this option include a permissions check or something? When I enable it the menu block is hidden on pages I have set to be visible to authenticated users only.
Comment #101
othermachines CreditAttribution: othermachines commentedWell, that's annoying. Here's a re-re-reroll. Thanks @rkent_87.
Comment #102
thtas CreditAttribution: thtas commentedThe patch in #101 applies against 2.7 just fine.
Still get the errors as in #98 though because i had existing configured menu_blocks from before the patch.
Comment #103
JKingsnorth CreditAttribution: JKingsnorth commentedMarked #406568: Show Parents of Active Menu Item (Starting level setting) as a duplicate.
Comment #104
bradallenfisher CreditAttribution: bradallenfisher commentedI just applied patch in 101, checked the box include parent, cleared the cached like 5 times, and nothing happend. The parent is still not included when there is only one menu item.
The patch did apply cleanly against 2.7, it just isn't doing what it is supposed to.
Comment #105
othermachines CreditAttribution: othermachines commented@bradallenfisher - Can you provide more info about your menu block configuration and the expected vs actual output?
Comment #106
bradallenfisher CreditAttribution: bradallenfisher commentedSure.
I have a menu block.
Menu = Main Menu
Include parent is checked
Maximum Depth = unlimited
expand all children is checked
fixed parent item is an item that doesn't have any children
I was under the impression this patch would show the parent item if there wern't any child items.
I have assigned the block to footer and only when I nest menu items under the parent does the block show.
Thanks.
Comment #107
knalstaaf CreditAttribution: knalstaaf commentedApplied patch #101 to the latest dev (2015-Oct-12), but now it only seems to display the parent (not accompanied by its children).
This is how my main menu looks like:
The menu block I'm looking for is this:
But what I'm getting is this:
This is my configuration:
Comment #108
othermachines CreditAttribution: othermachines commented@bradallenfisher
Thanks for the info. I was able to reproduce the problem.
Comment #109
othermachines CreditAttribution: othermachines commented@knalstaaf
Thanks for the detailed report; however there is some detail missing since I am unable to reproduce your problem on a fresh install with latest -dev.
By the way, what you should be getting with those settings (and what I am getting) is this:
(This feature doesn't flatten the menu.)
Comment #110
othermachines CreditAttribution: othermachines commented@bradallenfisher
This is actually by design.
The idea is to *include the parent in the menu*. It actually says in the description "The parent is not included if it was the only item in the menu." The wording isn't the best (it really should say
"has no children"(or better) "if the starting level contains no items"), but you get the idea.Feel free to convince me that the parent should be included in this case (I'm not 100% certain either way). In the meantime I'm setting this back to RTBC.
Comment #111
bradallenfisher CreditAttribution: bradallenfisher commentedI see. I always just use title as link if I want the parent included. It's under the advanced settings if you don't explicitly set a title.
My use case is if you have multiple menu blocks that you use to create a super footer and you want it to mirror your main menu. Everything is fine if all of your visible main menu items have nested items. If one or two don't then the menu block you create for that section isn't available. And you have to manually create the blocks with one link in them. So it's now not dynamic.
Comment #112
othermachines CreditAttribution: othermachines commented@bradallenfisher
Curious: why multiple menu blocks for a single menu? One for each top level section/page? Is it that you want to show only a particular section at a time, depending on active page? (This is pretty typical for sidebar submenus but when I think of a super footer I think of a fully expanded menu that doesn't change.)
Comment #113
bradallenfisher CreditAttribution: bradallenfisher commentedGood question! The requirement was that only 2nd level items (with parent item as header) be shown in columns in footer region matching parent items in top nav.
The way I read this issue (feels a little like i high jacked at this point) was that if you have a menu like
Parent 1
--child
Parent 2
-- child
Parent 3
Parent 4
--child
--child
that Parent 3 would be visible as a header item linking to its page.
That way in the future if someone adds items to it they just appear and you also have the same structure as the top menu.
All this is making me think we need a configurable super footer module now. ;)
Cause yeah its stupid adding 6 menu blocks to sitewide context.
Thanks.
Comment #114
othermachines CreditAttribution: othermachines commented@bradallenfisher
Hijacked - No, I actually think you've brought up a good question. Whether you meant to or not. :)
A common use case for a menu block is a sidebar submenu. Let's say we're in the ABOUT section. What this patch does (following this example, anyway) is it allows you to display this:
ABOUT
.. History
.. Press
.. Background
instead of this:
History
Press
Background
Now, when you scoot over to the CONTACT section, which doesn't have any children, you would see this:
Yep,.. nothing.
Without the parent displaying there, it seems inconsistent to me. Anyway, I'll leave it as-is for now and see if anyone else wants to chime in with an opinion.
As for your super footer, you could use a single menu block to print out the whole menu, then theme the mark-up to achieve a columnar display. Theming menus is kind of a pain in Drupal, but I do know a few tricks. Use my contact form if you want some help.
Good luck!
Comment #115
bradallenfisher CreditAttribution: bradallenfisher commentedCool thanks!
Comment #116
knalstaaf CreditAttribution: knalstaaf commented@othermachines: I'm using a flyout-menu workaround for the Bootstrap theme, which hides subitems by default (
.dropdown-menu
). I'll find a way around this.There's also this Bootstrap issue: #1850194: Add support for menu block module
Comment #117
othermachines CreditAttribution: othermachines commented@knalstaaf - Yes, I was going to suggest you look at that issue. What you report definitely isn't a Menu Block problem.
Comment #118
JohnAlbinThis module already has a "Block title as link" option which replaces the block title with the parent menu item, including its link.
To me, that already-implemented feature looks like a duplicate of this proposed feature. Feel free to re-open if you have an explanation of why this patch is needed.
Comment #119
sumachaa CreditAttribution: sumachaa at TATA Consultancy Services for TATA Consultancy Services commentedwe have 4 level menu items, when click on the 4th level menu item; is there a way to bring the parents starting from level 1 itself?
example:
level1
--level2
----level3
------level4_1
------level4_2
------level4_3
When selecting any menu is 4th level, need to bring all the parent items; please let us know if this is possible & how
Comment #120
C13L0 CreditAttribution: C13L0 as a volunteer commented@JohnAlbin
"Block title as link" only works when the title isn't overridden. In my case, I have to override the title due to the theme/design elements. Also, the design does not allow for -any- block titles to be links. This is exactly what I needed to correct the issue.
The patch in #101 works perfectly. Thanks!!
Comment #121
othermachines CreditAttribution: othermachines commented@JohnAlbin
Thanks for your attention to this. Although there may be some common use cases, replacing the block title isn't the same as including the parent in the menu, particularly from a themer's point of view. That there are 55 followers of this issue including a dozen-ish contributors reinforces that, I think.
Comment #122
othermachines CreditAttribution: othermachines commentedBack to RTBC,
Comment #123
agileadam#101 worked great for me. Thanks!
Comment #124
glass.dimly CreditAttribution: glass.dimly commentedI'd love to see an 8x version of this patch.
Comment #125
glass.dimly CreditAttribution: glass.dimly commentedWell, it doesn't look like this is going to get included in the 7x version.
However, the 8x version no longer has a "Block title as link" option, which is the reason @JohnAlbin gave for not wanting to include this functionality.
In my opinion, using "Block title as link" instead of rendering the parent menu item is a hack, because when the parent menu item link path or title changes, the block title link does not change. And also a different, non-menu method must be used to translate the block title.
So I've created a patch against the D8 version for this functionality.
Note: There was no good way to craft conditionals for the parameter object to include parent item in the tree (I think this is an oversight in the Drupal core menu code), so I retrieved the entire tree and searched it.
Comment #126
glass.dimly CreditAttribution: glass.dimly commentedComment #127
glass.dimly CreditAttribution: glass.dimly commentedI've updated the patch with minor UI changes to match the rest of the interface.
Comment #128
glass.dimly CreditAttribution: glass.dimly commentedUpdated the patch again to catch some errors.
Comment #129
Albert Volkman CreditAttribution: Albert Volkman commented@glass.dimly your patch is causing the top most ancestor to render, not the immediate parent.
Comment #130
Albert Volkman CreditAttribution: Albert Volkman commentedReworked the above patch to traverse all parts of the menu tree.
Comment #131
Albert Volkman CreditAttribution: Albert Volkman commentedAfter working through this... it seems this patch does the same thing, but much simpler-
#2884514: Add option to render 'fixed parent item' menu link
Comment #132
justcaldwellAlso consider #3082445: Add option to always render parent menu item, which is a reworked version of #2884514: Add option to render 'fixed parent item' menu link that should work with settings other than 'fixed parent item'.
Comment #133
Chris Matthews CreditAttribution: Chris Matthews as a volunteer and at City of Oaks Design commentedComment #134
komalk CreditAttribution: komalk at Srijan | A Material+ Company for Drupal India Association commentedRe-rolled the patch
Comment #136
pameeela CreditAttribution: pameeela commentedThis seems to be a duplicate of #3082445: Add option to always render parent menu item and although we usually keep the older issue open, that issue has a green patch and is RTBC so I'm going to close this one instead.
Comment #137
apemantus CreditAttribution: apemantus commented