Add advanced option to display children of current menu item

Created on 18 November 2022, about 2 years ago
Updated 28 January 2023, almost 2 years ago

Problem/Motivation

I need to have menu with children of current group content link.

Proposed resolution

Add advanced options how it is done on System Menus:

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Anna D

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

Comments & Activities

Not all content is available!

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

  • Status changed to Needs work almost 2 years ago
  • heddn Nicaragua

    NW for some minor feedback in the MR. But this is looking good.

  • Status changed to Needs review almost 2 years ago
  • heddn Nicaragua

    Do the features in ✨ Integrate some of Menu Block module's options Fixed solve things here?

  • Status changed to Needs work 28 days ago
  • heddn Nicaragua

    Needs a rebase

  • πŸ‡ΊπŸ‡¦Ukraine Anna D

    It seems merged advanced options in https://www.drupal.org/project/group_content_menu/issues/3366930 ✨ Integrate some of Menu Block module's options Fixed do same thing:

    Added 'follow_parent' attribute under this issue:

    +    // If we're following the active trail and the active trail is deeper than
    +    // the initial starting level, we update the level to match the active menu
    +    // item's level in the menu.
    +    if ($follow && count($parameters->activeTrail) > $level) {
    +      $level = count($parameters->activeTrail);
    +      $following = TRUE;
    +    }
    +
    +    if ($following && count($parameters->activeTrail) >= $level) {
    +      // Active trail array is child-first. Reverse it, and pull the new menu
    +      // root based on the parent of the configured start level.
    +      $menu_trail_ids = array_reverse(array_values($parameters->activeTrail));
    +      $offset = ($follow_parent === 'active') ? 2 : 1;
    +      $menu_root = $menu_trail_ids[$level - $offset];
    +      $parameters->setRoot($menu_root)->setMinDepth(1);
    +      if ($depth > 0) {
    +        $parameters->setMaxDepth(min($depth, $this->menuTree->maxDepth()));
    +      }
    +    }

    Added 'relative_visibility' attribute in #3366930 ✨ Integrate some of Menu Block module's options Fixed :

    +    $relative_visibility = $this->configuration['relative_visibility'] ?? FALSE;
    +    // If we're following the active trail and the active trail is deeper than
    +    // the initial starting level, we update the level to match the active menu
    +    // item's level in the menu.
    +    if ($relative_visibility && \count($parameters->activeTrail) > $level) {
    +      $level = \count($parameters->activeTrail);
    +      $menu_trail_ids = \array_reverse(\array_values($parameters->activeTrail));
    +      $menu_root = $menu_trail_ids[$level - 2];
    +      $parameters->setRoot($menu_root);
    +    }
    +
         // When the depth is configured to zero, there is no depth limit. When depth
         // is non-zero, it indicates the number of levels that must be displayed.
         // Hence this is a relative depth that we must convert to an actual
         // (absolute) depth, that may never exceed the maximum depth.
         if ($depth > 0) {
    -      $parameters->setMaxDepth(min($level + $depth - 1, $this->menuTree->maxDepth()));
    +      $relative_depth = $relative_visibility ? $depth : $level + $depth - 1;
    +      $parameters->setMaxDepth(\min($relative_depth, $this->menuTree->maxDepth()));
         }
    

    This issue and #3366930 ✨ Integrate some of Menu Block module's options Fixed both concern providing additional attributes from 'MenuBlock.'
    I'd vote to keep the same UI and avoid visual differences between editing Group Menus and Menus, but since it has already been merged, perhaps we can close this issue.
    Thank you.

  • πŸ‡ΊπŸ‡¦Ukraine Anna D
Production build 0.71.5 2024