If I use the menu block to display a menu in combination with the filterByCurrentLanguage menu manipulator, the settings of the max depth is ignored. The basic problem is, that the "menu_manipulator_preprocess_menu" function is called after the build process of MenuBlock.

Steps to reproduce

  1. Create in a menu various menu items in first and second level
  2. Place a Menu Block and with the options:
    • Initial visibility level: 1
    • Number of level to display: 1
  3. If you display the website, only the first level menu items should be visible.
  4. If you go to the parent menu (with a second level menu item), the parent and the submenu items are visible (expected: only the parent menu item [first menu level]).

Comments

cbeier created an issue. See original summary.

cbeier’s picture

Title: filterByCurrentLanguage ignores max depth in MenuBlock » filterByCurrentLanguage ignores max depth from MenuBlock
Issue summary: View changes
cbeier’s picture

Basically we need two things to get this to work:

  • In menu_block module, we need a way to alter the menu manipulators (to add "menu_tree_manipulators")
  • Parallel the current menu_manipulator_preprocess_menu() overrides the menu tree from the block build. So if we apply the language manipulator already in the block build, this hook must not be executed anymore.

Related: #2854013: Allow SystemMenuBlock tree manipulators to be altered

matthieuscarset’s picture

Assigned: Unassigned » matthieuscarset
Status: Active » Needs work

Hi @cbeier.

Thanks a lot for this detailed issue.

I agree that filtering of menus would be much better for compatibility, scalability and performance if done on the Block itself.

I will look into that shortly and push a fix soon - more likely not before second week of september.

zy’s picture

Hi,

I can confirm that the module does not respect settings on the core menu block eighter.

The main menu gets dropdowns (not intended), the second main menu block which should begin with level 2 becomes the exact copy of the "original" main menu, showing level 1 menu items with dropdowns.

Version: 8.x-2.0

j-lee’s picture

We have this issue too. Does anyone have a workaround for this?

matthieuscarset’s picture

As tried in this other issue, it does not seem possible for Menu Block to be compatible with any other module because it basically re-render the menu with its own configuration at the block level.

Reminder: a menu can be called and rendered programatically anywhere in Drupal.

Workaround: there is an issue with a patch for the Menu Block module.

matthieuscarset’s picture

Status: Needs work » Closed (won't fix)