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, about 1 month 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.
  • 🇬🇷Greece bserem

    @lobsterr it would be wise to grant credit to the people who have worked on this over the last 7 years and provided fixes to the issue by contributing patches until one of the maintainers sat down to deal with the issue.

    Crediting yourself alone is not the way to encourage people to work on open source projects.

  • 🇧🇪Belgium lobsterr

    Well, it wasn't my intention. Honestly, I didn't even try to take all credits for this ticket.

    but when you create MR it automatically assigns participants.

    If you know the way how to do it I will. The only way I see here is to create an empty commit.

  • 🇬🇷Greece bserem

    It's good to know it wasn't intentional, that means a lot :)

    As a maintainer you can see at the bottom of the drupal issue (above the green action buttons) the "Credit & Committing" section.
    In there you should have an option to check/uncheck who participated.
    I am adding a screenshot of this area from a different module, just to highlight how it looks like.

    You can chose whoever you want. It is customary to pick people who contributed with a patch and/or testing notes (even if not providing code patches).

    Once you fix the issue, and after 14days pass when it gets closed, people will get credit.
    It also gives you the commit message if needed, but I believe it is enough to just do the checkboxes.

  • 🇧🇪Belgium lobsterr

    Ok, thanks for info, I was always thinking it takes info from the commit message!
    I have credited participants!

  • 🇬🇷Greece bserem

    Much appreciated mate!

    Have a nice day

Production build 0.71.5 2024