0

I have the following menu items

- Menu item 1
--  Menu item 1 child
- Menu item 2
- Menu item 3
--  Menu item 3 child
- Menu item 4

I have the id of the Menu item 3 like menu_link_content:bda6f3cc-966d-41de-ba72-6d82f8933a00 . How can I display all the siblings of this menu item and also this menu item as expanded. i-e

- Menu item 1
- Menu item 2
- Menu item 3
--  Menu item 3 child
- Menu item 4

I tried the following code.

$params = new MenuTreeParameters();

// Set the root only if a child item was selected.
$params->addExpandedParents(['menu_link_content:bda6f3cc-966d-41de-ba72-6d82f8933a00']);

$menu_tree = $this->menuLinkTree->load($menu, $params);
$menu_tree = $this->menuLinkTree->transform($menu_tree, [
  ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
  ['callable' => 'paddle.menu_tree_manipulators:filterByCurrentLanguage'],
]);

But this is not displaying the results like I want? It only displays the child that menu item. How can I achieve it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.