Problem/Motivation
We have a multi-language menu with an item pointing to a node. When accessing a specific language where the node is not translated, the link does not appear because the menu_multilingual module filters it out. This is the expected behavior. However, with the translatable_menu_link_uri module, we are overwriting the link in the language where it does not appear with an external URL, so it should not consider the unpublished node condition.
Steps to reproduce
- Create a multi-language menu in Drupal.
- Add a menu item pointing to a node.
- Ensure the node is not translated into a specific target language.
- Enable the menu_multilingual module and the translatable_menu_link_uri module.
- Configure the menu item so the link points to an external URL in the targeted language.
- Try to access the menu in the language where the node is not translated.
Proposed resolution
The menu_multilingual module hooks into the pre-render phase, whereas translatable_menu_link_uri hooks into the preprocess phase. To resolve this issue, it is suggested that the menu link be altered in the pre-render phase.
Issue fork translatable_menu_link_uri-3472291
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
eduardo morales albertiComment #4
eduardo morales albertiPreviously applied the issue #3252404: Avoid extra DB query per menu item
Comment #5
eduardo morales albertiAlso fails because \Drupal\Core\Menu\DefaultMenuLinkTreeManipulators::checkAccess, if the menu link is not updated before BlockViewBuilder::preRender.
Comment #6
eduardo morales albertiComment #7
eduardo morales albertiAfter reviewing the Drupal Issue Queue the best short-term solution is to use the patch from #3091246: Allow MenuLinkTree manipulators to be altered to alter the menu link tree.
Comment #8
eduardo morales albertiWe will create a new branch and MR with the manipulators approximation if the issue #3091246: Allow MenuLinkTree manipulators to be altered is fixed.
Comment #11
eduardo morales albertiCreated MR https://git.drupalcode.org/project/translatable_menu_link_uri/-/merge_re... using menu tree manipulators strategy.
Comment #12
eduardo morales albertiComment #13
eduardo morales albertiComment #14
jsobiecki commentedHello Eduardo,
Thank you for your patch. Unfortunately, I need to put it on pause. The reason behind this is that you are using code that is not part of Drupal core. The fragments you are using are still in development at the moment (https://www.drupal.org/i/3091246 ) and needs work.
Generally, I like the approach as it axe's some old hooks, but since it's not yet part of core, I'd rather wait.
Maybe good idea would be to start release 3.x after the dependent change will be part of both 10.x and 11.x branches of Drupal. I think axing 9.x and 8.x is not a bad thing at this moment.