I have created a views page display that has the path /node/%node/sessions, contextually filtering by content ID. It also creates a "menu tab" called "Sessions".

Therefore when I got to node/12 I see a local tasks menu: "View / Edit / Sessions" etc.

When I go to /node/12/sessions I see my view, filtered correctly by 12, but WITHOUT any local tasks tabs.

How should I make a local tasks menu appear on the view page node/12/sessions, (with the local tasks the same as the node/12 but with the sessions tab as active)?

Using this entry in my_module.links.task.yml succeeds in adding an entry to the node local tasks (still present if 'no menu' is selected in view UI). But it doesn't add the node local tasks to the views page.

  title: Sessions
  route_name: view.event_sessions.page_1
  base_route: entity.node.canonical

Using views.view.event_sessions.page1 as the route throws a route not found error (although that is usually the correct route for a views page, so that's weird).

  • You will need to add it in a MODULENAME.links.task.yml file. Note that routes added by views have a special pattern, i think it is views.view.VIEW_NAME.DISPLAY_NAME
    – Eyal
    Mar 7, 2017 at 21:12
  • That works for pages added by page_manager, but not those added by views. Also setting entity.node.canonical as the base route via hook_local_tasks_alter doesn't work either. hook_menu_local_tasks_alter doesn't even fire on a views page.
    – Jonathan
    Mar 8, 2017 at 11:36
  • It should work, can you add your tries to the question. Maybe you made a mistake in the definition.
    – Eyal
    Mar 8, 2017 at 11:54
  • Do you have any arguments that need to be passed to this route?
    – Eyal
    Mar 8, 2017 at 17:06
  • There are two classes that you can debug to find the why the suggested solution doesn't work: Drupal\Core\Menu\LocalTaskDefault & Drupal\Core\Menu\LocalTaskManager. The first is the default class that represents your local task, and the second is the manager.
    – Eyal
    Mar 8, 2017 at 20:18

2 Answers 2


@Eyal was right. Some information:

  • Find the current route : /devel/routes gives you all the registered routes.
  • Or better : use the devel module & web profiler submodule to display the Symfony2 toolbar, you will have a lot of useful information, especially the current route.

    You should find a route name as view.my_page.page_1 for example.

  • Create a modulename.links.action.yml (or modulename.links.local.yml) with this content:

  route_name: view.my_page.page_1
  title: My button title
    - view.my_page.page_1

I created a view at /node/%node/authors that just lists the author of the node. I did not create a menu link in the views ui.

In MODULE.links.task.yml, I have:

  title: Authors
  route_name: view.authors.page_1
  base_route: entity.node.canonical

After clearing the cache, I have an Authors tab on the node, and when I'm on the views page, I have the usual view, edit, etc tabs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.