1

I am trying to create links in my Drupal 8 module, following this tutorial. So far, I have a link as follows in my module.links.menu.yml file:

module.admin_settings:
  route_name: module.adminForm
  title: 'Module Configuration'
  description: 'Set up module on your website'
  parent: system.admin_config_system

My question is, how do I find all possible values for the parent property? I looked in the docs but couldn't find one. However, there is a paragraph in the above tutorial which says:

Determining the parent menu_link name can be a little tricky at first. If you know the path of the parent menu item, you would need to search for it in all available *.routing.yml files (most text editors and IDEs should allow you to search all files in a project) and find the route name for that path. Then, you would need to search for the route name in all available *.links.menu.yml files. The menu_link whose route_name matches is your link. Alternatively, if you know which module is defining the parent menu link (or one of the parent menu link's children), you can go straight to that module and perform your search.

But I am not sure I understand as I am new to Drupal. Is there an easy way to find the set of possible parent values?

Thanks.

0

You can go to the menus structure and click on edit of the menu link under which you want to place the new link. The example from your question would open in this url:

/admin/structure/menu/link/system.admin_config_system/edit

Then you'll find the parent name in the slug before /edit.

But the easiest way is to register the menu link without parent, which would place the new link in the top level of the menu and then drag and drop the link where you want it to be.

You probably need to specify the menu name in the yaml file:

menu_name: admin

In the exported configuration the links you've moved in UI appear in this configuration file:

core.menu.static_menu_link_overrides.yml

where you'll find the parent value where you dragged the link to. You could then use this information for module.links.menu.yml, if you want to deliver your module with this information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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