0

I've created a custom route for each nodes, let's say /custom-page/{node}, which renders some specific stuff from a Controller.
On this custom page, I'd like to automatically display the same local tasks as displayed on nodes canonical pages (In my case : View, Edit, Delete, Devel)

I know I can set dynamic local tasks using a Deriver in links.task.yml but how can I load local tasks from another route ?
Or maybe there is a way to tell Drupal to display local tasks as if it was for the route "entity.node.canonical" ?

Thank you for your help !

0

2 Answers 2

1

CUSTOM_MODULE_NAME.links.task.yml

CUSTOM_MODULE_NAME.tab_view:
  title: 'TAB NAME'
  route_name: CUSTOM_MODULE_NAME.CUSTOM_PAGE
  base_route: entity.node.canonical
  weight: 5

CUSTOM_MODULE_NAME.routing.yml

CUSTOM_MODULE_NAME.CUSTOM_PAGE:
  path: 'node/{node}/abc'
  defaults:
    _controller: '\Drupal\MODULE_NAME\Controller\CONTROLLER_NAME::ACTION_NAME'
    _title: 'TITLE'
  options:
    parameters:
      nodeId:
        entity_type: node
  requirements:
    _permission: 'access content'
0

Ok actually this was a stupid question... I was trying to add the node tabs on my custom page without adding a tab to this custom page on the node view itself (entity.node.canonical)
Simply adding the new local task on the node view automatically displays other tabs when viewing any of the tabs

my_module.links.task.yml :

my_module.my_custom_tab:
  route_name: my_module.custom_page
  title: 'Custom'
  base_route: entity.node.canonical

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.