Hi, As the name of the title.
If you add a menu item via the UI and add a link with the value "#what-we-do", this value will not show in the response when loading this menu.
I have attached an image showing the admin page where I add this value, and another image showing the response for this menu item.
Please note that this is for a decoupled website and so I am not able to add a relative link (or even an absolute url). All I need is a hash value and the decoupled website will do the rest when it receives this hash value.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | nolink_route.png | 78.1 KB | ainarend |
| Screen Shot 2019-07-16 at 20.10.09.png | 23.77 KB | harcher | |
| AwesomeScreenshot-Edit-menu-link-Contenta-JSON-API-2019-07-16-20-07-67.png | 121.93 KB | harcher |
Comments
Comment #2
harcher commentedComment #3
fabianderijkHmmm okay, weird. I'll take a look at it!
Comment #5
fabianderijkThis is now fixed in the dev version. You can enable the checkbox to add the fragment on the settings page (admin/config/services/rest_menu_items). The fragment is then added to the alias, absolute url and relative url.
Comment #6
ainarend commentedHey, sorry to be a party pooper, but I feel that we missed one additional Drupal feature. In our Drupal projects I have seen clients use the # in the menu link urls to create a no link menu item.
The no link menu items are used for example when the menu has 2 levels and the editors want to create a first level element that doesn't link anywhere, but allows opening the dropdown to the second level.
And in my eyes, as using # and everything that comes with it works automagically with coupled Drupal menus, i'd expect this to work for the decoupled menu as well, without any additional configuration, so in my eyes the default option for the new configuration item should be checked, not sure about BC here for existing sites).
Simplytest site showing my use case:
The site:
https://drgit.ply.st/
Main menu API response, showing that the no menu item is missing the # in alias:
https://drgit.ply.st/api/menu_items/main
Comment #8
fabianderijk@ainarend, I would discourage using the # for non-linking menu items. In Drupal 8 you can use
route:<nolink>for that.About the option being enabled by default, I checked this and I don't think this will cause any issues. I will however only set in in the install config yml, so it will work with new installs. Existing installs will need to enable the option manually. This is already available in the dev version of the module. Once we have more bug-fixes, new features or we don;t in about 2 weeks I will release a new stable version.
Comment #9
ainarend commentedOf course, i forgot about the
route:<nolink>. Thanks! I have nothing more to add, seems that everything else is all good.Hopefully this will serve as sort of documentation for some one like me in the future :D I'll add a quick screenshot of the API result as well, mind that when using the nolink route there is no uri, alias or any other url related properties in the response, so that's something that people using the response should be aware of.
Comment #10
harcher commented@fabianderijk, that fixed my issue, the hash value/fragment is showing now. Thanks!