Hi,
I would like to add a new option to "Starting level will be" :
"Children of active menu item, and active menu item if no children"
It would be useful if you want to display children of active menu item and the "brothers and sisters" in the last depth.
It permits to add tabs in last depth.
I'm sorry i don't know how to suggest a .patch, but i can describe the only change in code.
In menu_block.admin.inc:
Line 388 : add 'child_active' => t('Children of active menu item, and active menu item if no children'),
You will have following code:
$form['follow_parent'] = array(
'#type' => 'select',
'#title' => t('Starting level will be'),
'#default_value' => $follow_parent,
'#options' => array(
'active' => t('Active menu item'),
'child' => t('Children of active menu item'),
'child_active' => t('Children of active menu item, and active menu item if no children'),
),
'#description' => t('When following the active menu item, specify if the starting level should be the active menu item or its children.'),
'#states' => array(
'visible' => array(
':input[name=follow]' => array('checked' => TRUE),
),
No additionnal change, it seems to work for me. :)
Let me know if you have remarks or questions about this feature...
Comment | File | Size | Author |
---|---|---|---|
#1 | menu_block-children_or_active-1620298-1.patch | 614 bytes | Dentorat |
Comments
Comment #1
Dentorat CreditAttribution: Dentorat commentedThanks, I was looking for this option. Here is the fix in patch form for 7.x-3.x-dev
Comment #2
killua99 CreditAttribution: killua99 commentedThis work in the 2.3 branch. But need a patch.
Comment #3
cabplan CreditAttribution: cabplan commentedHoly crap, you have saved my life!!! I have been looking for two days trying to figure out how to get this working, could not figure out why this was not built into the UI from the get-go. Thank you for posting this, totally fixed my issue of not having children items but keeping the same level items as a menu.
Comment #4
syturvy CreditAttribution: syturvy commentedDoes this still work in version 2.4?
Comment #5
gmclelland CreditAttribution: gmclelland commentedI don't how this one line of code works, but the patch in #1 works fine with everything I've tested on the latest 7.x-2.x-dev.
Comment #6
gmclelland CreditAttribution: gmclelland commentedLooks like this still works and applies with the latest 2.5 or 2.x-dev versions.
Comment #7
gmclelland CreditAttribution: gmclelland commentedThis seems very similar to the patch posted at #758184: Show items on same level if active menu level doesn't have children. Can anybody confirm or explain the differences?
Comment #8
webczarina CreditAttribution: webczarina commentedThis patch works for me with Menu Block 7.x-2.8. However, now I need the same functionality in Drupal 8, and that doesn't exist.
Comment #9
jwilson3I have a patch ready for Drupal 8, but I'm trying to decide where to put it.
Re #7, comment #29 on #758184-29: Show items on same level if active menu level doesn't have children outlines the difference. Basically, the patch from Comment #1 above and from Comment #26 on that issue are nearly the same, just worded differently, and the patch in that issue has more comments to explain what is going on. There are also 2 other issues (listed below) with patches are much more complex, but effectively do the same thing — show siblings when the current active item has no children.
I would propose the following three issues be closed as a duplicates because #758184 predates all of them and has more followers than any of these others combined. I will put my D8 patch there.
* #1125154: "Deepest item in the active trail with visible siblings" as option for follow_parent
* #1620298: Add new starting level option "Children of active menu item, and active menu item if no children" (this issue)
* #1650684: [Pull request] Show siblings at deepest level