Show items on same level if active menu level doesn't have children

Created on 31 March 2010, about 15 years ago
Updated 6 May 2024, 11 months ago

Problem/Motivation

Version 6.x-2.2 of Menu Block module had a key feature that would fallback to showing items on the current level (i.e. siblings to the active menu item) when the active menu item doesn't have any children.

Neither Drupal 7 nor Drupal 8/9 versions of the Menu Block module have this feature.

This is a very common use case for creating a sidebar secondary nav that is only ever supposed to be one or two levels deep at any given time, but is setup to always show as much relevant information as possible.

Steps to reproduce

If a menu block is configured to:

  • show 1 level,
  • follow the active menu item,
  • set the initial visibility rule to show Children of active menu item.

then when the user clicks on any child link, the menu display is less than helpful and only contains a single item (the current page).

Proposed resolution

Add a third option to the "Initial visibility level" radios:

  • Active menu item
  • Children of active menu item
  • New option: Children of active menu item; active menu item if no children

Remaining tasks

User interface changes

Users will see a new option in the menu block configuration screen.

API changes

The follow_parent menu block setting variable will respond to a new option called child_or_active in code.

Data model changes

N/a

Feature request
Status

RTBC

Version

1.0

Component

Miscellaneous

Created by

🇷🇺Russia temp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada joelpittet Vancouver

    Ran out of time to test and commit this so moving to the next release

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 7.4 & MySQL 5.7
    last update 11 months ago
    Composer require failure
  • 🇺🇸United States daniel korte Brooklyn, NY

    Reroll

  • First commit to issue fork.
  • Merge request !21MR created. → (Open) created by chaitanyadessai
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 7.4 & MySQL 5.7
    last update 11 months ago
    Unable to generate test groups
  • Pipeline finished with Success
    11 months ago
    Total: 211s
    #170662
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 7.4 & MySQL 5.7
    last update 11 months ago
    Composer require failure
  • 🇺🇸United States greenskin

    We have a need for this feature. Additionally we needed the title/label to reflect similarly, where it displays the active item's title when it has children otherwise it displays the parent's title. This patch is a re-roll of #42 with a new block label option that will use the active item's title when the item has children, otherwise uses the parent title.

  • Issue was unassigned.
  • Status changed to Needs work 2 months ago
  • 🇨🇦Canada joelpittet Vancouver

    @greenskin, it looks like you merged stuff from a different issue which conflates this issue, I feel like I have seen that elsewhere but haven't been able to spot it. Can someone ensure this is working with what the issue summary suggests on MR21 please?

    I am hiding the patches as I would prefer an Merge Request.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 186s
    #442064
  • Pipeline finished with Success
    about 1 month ago
    Total: 181s
    #442069
  • Merge request !36Reroll → (Open) created by daniel korte
  • Pipeline finished with Success
    about 1 month ago
    Total: 182s
    #442075
  • 🇺🇸United States daniel korte Brooklyn, NY

    Apologies for the noise. I tried to fix the merge request, but it did not go well so I created a new branch that is now mergeable.

  • 🇪🇨Ecuador jwilson3

    I can confirm the MR #36 is a faithful reroll of the patch in #42 (without the extraneous code added in #45 and #46).

    Thanks for the work @danielkorte

Production build 0.71.5 2024