Match MenuTreeStorage->loadByRoute on wrapped nodes

Created on 13 April 2021, almost 4 years ago
Updated 14 February 2025, about 2 months ago

Problem/Motivation

When viewing group_content entities that wrap nodes, it would be nice if MenuTreeStorage->loadByRoute would match on those wrapped nodes. This enables menu.active_trail service to work on group_content entities that wrap nodes.

An alternative way to get active trail working on group_content entites be to use https://www.drupal.org/project/groupmenu/ . However that module doesn't seem actively maintained and is currently not D9 compatible.

This implementation is limited to the gnode sub module and makes an effort to be as light as possible.

Steps to reproduce

- Enable group + gnode modules
- Add a node to a group
- Add that node to the main menu
- Visit the group_content path
- Notice that active trail is not respected

Proposed resolution

- Decorate the menu.tree_storage service
- Override the loadByRoute method
- Return results for the wrapped node if current route is a group_content route that wraps nodes

Remaining tasks

- Community feedback / testing

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States zweishar

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.

  • 🇷🇴Romania reszli Târgu Mureș

    updated patch that fixes PHP 8.2 deprecation errors:

    Deprecated function: Creation of dynamic property Drupal\gnode\MenuTreeStorage::$inner is deprecated in Drupal\gnode\MenuTreeStorage->__construct() (line 38 of modules/contrib/group/modules/gnode/src/MenuTreeStorage.php).
    
    Deprecated function: Creation of dynamic property Drupal\gnode\MenuTreeStorage::$route_match is deprecated in Drupal\gnode\MenuTreeStorage->__construct() (line 39 of modules/contrib/group/modules/gnode/src/MenuTreeStorage.php).
Production build 0.71.5 2024