0

For some content type, I need to attach my node to a parent menu item. I don't want to do that with UI (because too many nodes). I saw something like that for Drupal 7 (works in a preprocess):

menu_tree_set_path('main-menu', 'my/parent/path');

Do you know a way to do that with Drupal 8 (menu_tree_set_path seems undefined) ?

1 Answer 1

2

The menu active trail is defined by the menu.active_trail service. Unfortunately it doesn't use a tag based extension like breadcrumbs.

You can replace that service and in case you detect that you're on a patch displaying a certain content type, return your desired structure.

You could also try out the https://www.drupal.org/project/menu_trail_by_path module, which defines the active trail based on the aliased path, like breadcrumbs do by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.