0

Is it possible to create my own Parent / Sub-Menu in the Configuration tab in Administration?

Every resource I find seems to give an example of the yaml file placing a link under the Development menu, with system.admin_config_development, but I want one in (for example), system.admin_config_MYMENUNAME .

Example of current yaml file (hello_world.links.menu.yml) :

hell_world.admin:
  title: 'Hello module settings'
  description: 'example of how to make an admin settings page link'
  parent: system.admin_config_development # want this to be system.admin_config_MYCUSTOMMENU
  route_name: hello_world.content
  weight: 100
1

Just use this parent route: system.admin_config (/admin/config)

See example from Drupal core.

system.admin_config_search:
  title: 'Search and metadata'
  route_name: system.admin_config_search
  parent: system.admin_config
  description: 'Configure site search, metadata, and search engine optimization.'
  weight: -10
0

Just thought it would be easier to show a basic example that has both parent and submenu item in the mymodule.links.menu.yml.

Right now both links goto the same place (as I had to pick a default for the parent item, since I didn't have a admin page that lists all my custom links yet ... and also since having "route_name: <nolink>" did not work for the parent menu item even though some peeps said it worked for them [Note: using Drupal 8.6.12]):

mymodule.parent:
  title: 'My MainMenu Link'
  parent: system.admin_config
  description: 'Custom main config menu item under the Admin->Configuration menu.'
  route_name: mymodule.form
  weight: 100

mymodule.parent_child:
  title: 'My Submenu Link'
  parent: mymodule.parent
  description: 'This is the sub-menu item for my custom config form.'
  route_name: mymodule.form
  weight: 101

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.