Quantcast
Viewing all articles
Browse latest Browse all 295264

Enabled subtree links of a disabled parent link are added to the menu tree at the wrong depth.

Problem/Motivation

Having the following menu tree:

- item 1 (disabled)
-- item 1a
-- item 2a
- item 2
-- item 2a 
- item 3

Then fetch the full menu tree with only enabled menu items:

$parameters = new MenuTreeParameters();
$parameters->onlyEnabledLinks();

$tree = \Drupal::service('menu.link_tree')->load($menu_name, $parameters);

I expect to get the following tree:

- item 2
-- item 2a 
- item 3

Instead I get:

- item 1a
-- item 2a
- item 2
-- item 2a 
- item 3

Proposed resolution

Don't add enabled subtree items to the tree when the parent item is disabled and the menu tree is build with the "onlyEnabledLinks" parameter set.


Viewing all articles
Browse latest Browse all 295264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>