1

Based on the official documentation to create menu links I've tried to use an internal link on the administration menu. But the internal link is only visible for users with administrator rights.

In my my_module.links.menu.yml I use the following links for testing:

my_module.test_link:
  title: 'TEST LINK internal'
  url: internal:/node/add
  description: 'TEST internal'
  parent: system.admin_content
  weight: 99

my_module.test_link_2:
  title: 'TEST LINK external'
  url: https://www.stackoverflow.com
  description: 'TEST external'
  parent: system.admin_content
  weight: 100

Both links are visible for administrators, but an user with editor role does only see the external link.

I activate every permission for the editor role, the link remains invisible.

1 Answer 1

2

It seems to be necessary to use a route_name for this. Then you can control permissions and the internal link is visible for the editor role too:

1 – Change my_module.links.menu.yml to use a route_name instead of the url:

my_module.test_link:
  title: 'TEST LINK internal'
  route_name: my_module.test_route
  description: 'TEST internal'
  parent: system.admin_content
  weight: 99

2 – Add the route with permission to my routing file my_module.routing.yml:

my_module.test_route:
  path: '/node/add'
  requirements:
    _permission: 'access content'

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.