This question already has an answer here:
- Non-Clickable Menu Items 3 answers
I have been struggling/failing for the last day to try find a way that I can add a flag/marker to the Drupal menu links that I can examine within the menu TWIG template to modify the link such that it becomes plain text instead of a menu link.
I am not using any menu modules, standard Drupal Menu with CSS to provide the drop down functionality and styling.
What I need is to be able to output a menu item as shown in the screen shot, specifically the 'Sell your property' & 'Essential Services' items which are unlinked headers.
Initially I attempted to use the contributed module
menu item extras
(https://www.drupal.org/project/menu_item_extras) which works fine from a menu management plugin point of view but then they change the markup way too much and it actually breaks the drop down functionality, so I cannot use it.
I then tried a second module which seemed simpler, i.e.
Menu link content fields (https://www.drupal.org/project/menu_link_content_fields).
This module has some strange behaviour in that it makes the menu links fieldable. I can add a new field but after adding a field, it does not appear under the
Manage Fields tab, and in the twig template the new field is un-available in the menu item object (Examined through xDebug)
Also, trying to remove this invisible field at a later stage seems difficult.
Question: How can I easily add some sort of marker to a menu item link to allow me to modify the template output for said link. Or is the re a module that will allow then insertion of HTML markup/plain text instead of a link (Megamenu doesnt seem to allow this)
Also, I cannot seem to find the hook which deals specifically with a sites menu, i.e. the hook that is executed for each menu link. Does one even exist?
I'd like to avoid a hack whereby I put in a unique string into the text of the link and then examine this in the menu twig templates to see if that string exists to know if I need to modify it.