Allow altering 'menu tree' and 'menu tree manipulators' for the menu rendered by SuperFishBlock

Created on 16 November 2018, over 6 years ago
Updated 28 April 2025, 5 days ago

Superfish (and all Drupal menu modules for that matter) display all menu items in a menu, regardless if they are for a different language than the active one.

This is an ongoing discussion done on 🐛 Untranslated menu items are displayed in menus Needs work
Also a couple of modules were spawned to solve that problem:
https://www.drupal.org/project/menu_manipulator
https://www.drupal.org/project/menu_block_current_language
https://www.drupal.org/project/menu_multilingual

They have a different approach to the problem, with the first one being closer to drupal core issue.
None of them works out of the box for Superfish though.

To make this happen, we'll need to add an alter hook that will allow developers to alter the 'menu tree' or 'menu tree manipulators' or both if they want.

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇬🇷Greece bserem

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.

  • 🇧🇪Belgium lobsterr

    1) Since, we have already made manipulators alterable Make menu tree manipulators alterable Needs review , it is already possible to add it on your modules
    2) I wanted to add a solution from #2 to the module by default, but since there is work in progress and they are changing the names of methods. I am not going to include
    3) I like the approach to pass tree to a hook too, because Allow MenuLinkTree manipulators to be altered Needs work they also pass $tree to the event. So, let's add it too, but I propose to pass in the end to keep backward compatibility.

    function my_module_superfish_manipulators_alter(array &$manipulators, $menu_name= NULL, &$tree = []) {
      if ($menu_name == 'main') {
        $manipulators[] = ['callable' => 'menu.language_tree_manipulator:filterLanguage'];
      }
    }
    
  • @lobsterr opened merge request.
Production build 0.71.5 2024