- πΊπΈUnited States bkosborne New Jersey, USA
I think this belongs in Token's issue queue.
- π¨πSwitzerland berdir Switzerland
You can always implement your own tokens that limit to the menu you want, along the lines of _menu_ui_tokens(), this might be complex to do in a generic way.
That said, _token_menu_link_best_match() already at tempts to find the link that is used on the node edit form. If you only allow the main menu there, that should just work.
- πΊπΈUnited States bkosborne New Jersey, USA
Yeah, I was just investigating this too. If a node is part of multiple menus, Token will use the menu link that was part of the node form submission when resolving the token. Of course nodes can be saved outside of a form submission. In this case, it will defer to Menu UI's
menu_ui_get_menu_link_defaults
method to find the menu link to use. This is the same logic that Menu UI uses on the node form when selecting the menu link to show on the node form.So I think the solution here for nodes: edit the node type form and set the default menu to the one that you prefer to be used for token generation. I think the majority of the time whatever you have set as the default menu for the node type will match what you want pathauto/token to use.
- π¨πSwitzerland stefanos.petrakis@gmail.com Biel, Switzerland
stefanos.petrakis β made their first commit to this issueβs fork.
- Merge request !96Resolve #2952612 "Best match interface" β (Open) created by stefanos.petrakis@gmail.com
- π¨πSwitzerland stefanos.petrakis@gmail.com Biel, Switzerland
Here is an naive idea using events.
The reasons behind it:(a) Using the default menu and relying on the node edit form, works by extending the complexity of the node edit form, which may not be ideal in some cases. And also, this approach does not work when going via Pathauto (and any other programmatic use of related tokens).
(a) Implementing custom tokens would work, but then, one would be missing (and probably copy-pasting) all the goodness that comes with the current implementation of token_tokens()Putting this out there as it does help us solve our version of the same problem.