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.
John Cogan 2018-10-09 09:54:45Z
您需要先启用Twig调试： Ismail Cherri 2018-10-09 10:45:28Z, License: CC BY-SA 4.0
我已安装并启用了Twig调试。模板不是我的问题。 John Cogan 2018-10-09 10:51:51Z, License: CC BY-SA 4.0
附加的重复答案的问题解决问题，并允许我基于路由的至少更改样式：<nolink> </ nolink> John Cogan 2018-10-11 09:59:09Z, License: CC BY-SA 4.0
You need to enable Twig Debugging first: Ismail Cherri 2018-10-09 10:45:28Z, License: CC BY-SA 4.0
I have got twig debugging installed and enabled. Templating is not my issue John Cogan 2018-10-09 10:51:51Z, License: CC BY-SA 4.0
The attached duplicate answer sdolved part of the problem and allowed me to at least change styling based on the route:<nolink> John Cogan 2018-10-11 09:59:09Z, License: CC BY-SA 4.0