0

So here is what I've tried in custom module dir I've created module.links.menu.yml file here is code. I want to just for authenticated user beside Content link have my custom link to access Webform. Also, do I need routing file to?

description: "Link descr" menu_name: main parent: system.admin url: 'internal:/admin/structure/webform' route_name: entity.webform.collection title: "Webforms" weight: -48 requirements: _role: 'authenticated' 

1 Answer 1

1

Given that you are simply moving a link of an existing route in a drupal menu, you are probably better off using the more simple hook_menu_links_discovered_alter(). A custom link/route is probably a bit of overkill.

But, presuming you do want to go the way you are in your example, you would need to have both a my_module.routing.yml and my_module.links.menu.yml

In the menu links file you might have something like:

my_module.hello_admin_user: title: 'Hello Admin User' description: 'See a Hello Admin User Message' parent: system.admin_config_development route_name: my_module.hello_user weight: 100 

and in the routing file you might have:

my_module.hello_user: path: '/hello-user' defaults: _controller: '\Drupal\my_module\Controller\MyModuleController::helloUser' _title_callback: 'Hello Admin User' requirements: _permission: 'access content' _role: 'authenticated' options: _admin_route: TRUE 

You've got a bit of a mix going in your example. Note that route names and links names need to be unique across the drupal system. Using your module name as the start is a convention but not required.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.