2

I want to create a menu in the admin section that is in the sitename/admin/config path.

As of now, I am doing this.

Routing file

custom_menu.adminmenu_section:
    path: '/admin/config/custommenu'
    defaults:
        _controller: 'Drupal\custom_menu\Controller\CustomMenuController::content'
        _title: 'Custom Menu Configuration'
    requirements:
        _permission: 'administer site configuration'

custom_menu.admin_menu:
    path: '/admin/config/custommenu/customconf'
    defaults:
        _form: 'Drupal\custom_menu\Form\CustomMenuForm'
        _title: Custom Menu creation
    requirements:
        _permission: 'administer site configuration'

links.menu file

custom_menu.adminmenu_section:
    title: 'Configuration'
    description: 'Custom Menus Configuration section'    
    parent: system.admin
    route_name: custom_menu.adminmenu_section

custom_menu.admin_menu:
    title: 'Custom Menus Conf'
    description: 'Custom Menus Configuration section'
    parent: custom_menu.adminmenu_section
    route_name: custom_menu.admin_menu

This code is not creating a section in the admin/config path. But when I used parent: system.admin_config that time I will get menu in the admin section but the section name will be CONFIGURATION. Because its title given in the system.admin_config route, but I don't want that name.

I want to create a section with separate name. How can I achieve that?

1 Answer 1

2

I tested it with your code and you just have to change two little things in your custom_menu.adminmenu_section. The rest is ok. See below:

module.links.menu.yml

custom_menu.adminmenu_section:
  title: 'Configuration' <= change this to your section name
  description: 'Custom Menus Configuration section'    
  parent: system.admin_config  <= change this to system.admin_config
  route_name: custom_menu.adminmenu_section
2
  • Ohh nice.. I got it now. But previously also i was giving Configuration in a lower letter only rite.. why that was not working? In system.admin_config its in a capital letter..
    – Suraj
    Commented Jun 2, 2017 at 6:49
  • In configuration basic theme of drupal 8 the headlines are uppercase...
    – schneidolf
    Commented Jun 4, 2017 at 14:06

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.