Hola,
I've been getting used to doing D8 development by porting a module over to D8 and in doing so, I found a strange bug (? I can only assume its a bug) within the routing system.
So in my module, I have a path (/admin/appearance/manage/google_webfont_loader_api) which is an administrative page within the appearance section.
However, when I first got rid of hook_menu and solely used the routing.yml file, I found out that the 'Google Webfont Loader Settings' tab was now gone (I was able to bring it back by implementing hook_menu again - why both routing and hook_menu are necessary when we used to have solely hook_menu perplexes me but as far as I have been told to accept, "it is what it is"). But last week, I found out that even though the menu item is missing, the route is still accessible. So I went to take a look and I found an interesting result:
(These are just unedited screenshots but I hope it is easy enough to see the different)
The parent item (at admin/appearance) seems to inject some of its own content onto the page (along with setting the menu item tab to 'list'). So while the routing/menu stuff may be intentional, this part of the behavior certainly seems like a bug. I'm happy to help provide any other information as necessary.
Comment | File | Size | Author |
---|---|---|---|
parent-takes-over.png | 170.98 KB | BTMash | |
goal.png | 152.31 KB | BTMash |
Comments
Comment #1
dawehnerYou should also convert your local task to use the new LocalTask plugin. Then it should probably work.
Comment #2
BTMash CreditAttribution: BTMash commentedI'm a bit confused by this...are there any examples of this somewhere (looking through the codebase, I see the localtask tests but that is about it)? Also, the page I have for this currently extends SystemConfigFormBase (since my page is configuration form).
Comment #3
BTMash CreditAttribution: BTMash commentedAlso, I should note that if I implement hook_menu (and just make it into a menu_callback if I wanted it hidden or set it as menu_local_task for the menu type), then it works as expected (though ideally, I would prefer to avoid implementing hook_menu altogether if possible, even if this wasn't a local task).
Comment #4
dawehnerAt the moment you either go with just hook_menu() based approach, or you just use a route entry + a local task plugin.
Just have a look at
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsSettingsTask.php
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsSettingsBasicTask.php
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsSettingsAdvancedTask.php
core/modules/views_ui/lib/Drupal/views_ui/Plugin/Menu/LocalTask/ViewsListTask.php
Comment #5
pfrenssenI encountered this with a subpath that is not a local task, but a regular MENU_CALLBACK. It occurs when deleting a language in the language module. I need to leave this in hook_menu() otherwise the help text, local tasks and local actions are inherited from the parent path
admin/config/regional/language
.I also notice that when I enter a random subpath to a page that contains help texts, local tasks, or local actions, then these are displayed on the resulting 404 page. For example if you go to
admin/structure/types/lalala
you see the local action "Add content type" on the 404 page.Comment #6
pfrenssenMy remark from #5 has been fixed in the meanwhile.
Comment #7
dawehnerThat kind of stuff is also fixed in the meantime