Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In the D7 version of this module menu items were created based on the path and the configuration of the config page
http://screencast.com/t/EUYOoRQBfaSe
This way I could see the link to configure the frontpage on the admin toolbar.
In D8 I don't know how to do this.
I'll try a mymodule.links.menu.yml
Comment | File | Size | Author |
---|---|---|---|
#3 | menu-links-2791581-1.patch | 1.52 KB | icurk |
Comments
Comment #2
shumer CreditAttribution: shumer as a volunteer commentedComment #3
icurk CreditAttribution: icurk commentedHere is a patch, which creates menu links.
Comment #4
boshtian CreditAttribution: boshtian commentedI confirm that this patch works for me.
Comment #5
boshtian CreditAttribution: boshtian commentedComment #7
shumer CreditAttribution: shumer as a volunteer commentedThx for this patch, already committed to dev version, so will be available with new release.
Comment #8
rodrigoaguileraI found a little nitpick for this feature.
If I set the path to
/admin/config/system/general_configuration
Everything is OK
But /admin/config/system/general-configuration
fails to create the link.
Can we address this here?
Comment #9
rodrigoaguileraI think I was confused by my debugging sorry.
what made the link disappear is using "drush cr". Does not matter if the path contains "_" or "-".
I think using hook_menu_links_discovered_alter to add new links is a bit weird. I think the implmentation of this functionality should be closer to what views does starting with the MODULE_NAME.links.menu.yml
Also using t($variable) should be fixed.
Comment #10
icurk CreditAttribution: icurk commentedStrange... The issue is not with how the link is created, it has to do it with how you clear cache. If you run drush cr, then hook_menu_links_discovered_alter is not called, hence menu link is not created. But if you clear cache inside an administration, then this hook is called and menu link is created.
hook_menu_links_discovered_alter is the right way to do it, as this is one of the options written in drupal documentation "How to add dynamic menu links". And the other one is, as you said, with using deriver class in *.links.menu.yml file. I tested both options, but if you rebuild cache with drush menu links are not created.
Comment #11
rodrigoaguileraYou mean that you tried a deriver class and suffers from the same problem?
I tried to reproduce this with the menu links that views creates and I was no able to reproduce it so clearly config pages does something different.
Thanks for taking the time to look at it :)
Comment #13
GrimreaperHello,
I have the same problem. The menu links are not created. The parent is not detected.
I confirm that when using drush cr, the hook_menu_links_discovered_alter is triggered
On the line:
When in the execution of "drush cr", no route is found, but when executing using devel/php, it founds the right route.
Comment #14
rodrigoaguileraI still feel is a problem with drush so if anyone can produce a test case for them to help fix this bug that would be great
https://github.com/drush-ops/drush/issues/2683#issuecomment-311626273
Comment #15
shumer CreditAttribution: shumer as a volunteer commentedI can't reproduce this issue in my local environment. @Grimreaper or @rodrigoaguilera anyone of you still able to reproduce it? If so, please share STR with me. Thx.
Comment #16
shumer CreditAttribution: shumer as a volunteer commentedComment #17
shumer CreditAttribution: shumer as a volunteer commentedComment #19
shumer CreditAttribution: shumer as a volunteer commentedFixed.
Comment #21
flocondetoileI found a bug related to this commit.
If you create a custom path, let's say
/admin/config/cerema/activites
, for a config page, then if you flush routing and links cache (with the custom link provided by admin_toolbar_tools), you've got a fatal error.Because the parent
/admin/config/cerema/
do not correspond to any existing routes.As a workaround I added a custom route which correspond to the parent path.
Should we reopen this issue or create a new one ?
Comment #22
icurk CreditAttribution: icurk commentedI think that it would be better to create a new issue.
Comment #23
rodrigoaguileraJust FYI I do not suffer from the drush cr bug anymore with config pages 2.1 and drush 9