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...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dentorat’s picture

Version: 7.x-2.3 » 7.x-3.x-dev
Status: Needs work » Needs review
FileSize
614 bytes

Thanks, I was looking for this option. Here is the fix in patch form for 7.x-3.x-dev

killua99’s picture

This work in the 2.3 branch. But need a patch.

cabplan’s picture

Holy 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.

syturvy’s picture

Does this still work in version 2.4?

gmclelland’s picture

Title: Add a new option to "Starting level will be" » Add new starting level option "Children of active menu item, and active menu item if no children"
Issue summary: View changes
Related issues: +#1125154: "Deepest item in the active trail with visible siblings" as option for follow_parent, +#1650684: [Pull request] Show siblings at deepest level

I 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.

gmclelland’s picture

Looks like this still works and applies with the latest 2.5 or 2.x-dev versions.

gmclelland’s picture

This 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?

webczarina’s picture

This 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.

jwilson3’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#758184: Show items on same level if active menu level doesn't have children

I 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