0

I'm a Drupal 8 newbie writing my first module. I have a functioning yet basic module to learn from. What I'm working on now is for it to get a value from a configuration page. If I go directly to the URL for the custom config page it works. What I'm having trouble with is getting a link to my custom config page to display on the main config page. I've been through every tutorial I can find on this topic and I just can't figure out why it's not working. I hope you all can help. Here's my yml files.

itemrequest.info.yml

name: Item Request
type: module
description: Allow the public to request items for the District to purchase.
package: YCFLD
core: 8.x
configure: itemrequest.settings

itemrequest.routing.yml

itemrequest.itemrequest:
  path: '/itemrequest'
  defaults:
    _controller: '\Drupal\itemrequest\Controller\ItemrequestController::itemrequestpage'
    _title: 'Request an Item'
  requirements:
    _permission: 'access content'
itemrequest.settings:
  path: '/admin/config/itemrequest/settings'
  defaults:
    _form: '\Drupal\itemrequest\Form\ItemrequestForm'
    _title: 'Item Request'
  requirements:
    _permission: 'access administration pages'
  options:
    _admin_route: TRUE

itemrequest.links.menu.yml

itemrequest.settings:
  title: 'Item Request Form'
  description: 'Settings for Item Request form"
  route_name: itemrequest.settings
  parent: system.admin_config

Do see anything wrong in the .yml files? Is there anything I can do to troubleshoot this?

2
  • 1
    A don't see a menu_name in your itemrequest.links.menu.yml file specifying the menu it appears in.
    – beltouche
    Mar 24, 2020 at 1:55
  • 1
    I got it working and I didn't need a menu_name.
    – Chanel
    Mar 24, 2020 at 16:08

1 Answer 1

1

system.admin_config is the top-level page at /admin/config. Normally you would not put your configuration link there - you would instead put it into one of the blocks that appear on that page. For example, the "People" block would be user.admin_link, so if you want your config under "People" use user.admin_link as your parent. Or if you want to put your configuration link under the "Development" block use system.admin_config_development as your parent.

If you want to create your own top-level block then you need to do things a little differently - see the core user module and how it defines user.admin_link in user.links.menu.yml and user.routing.yml - this shows how a new block is created on the config page. You can then put your configuration link in that new block.

1
  • Changing system.admin_config to system.admin_config_development did the trick. Thank you! Now I'm going to see if I can figure out how to create my own top-level block.
    – Chanel
    Mar 24, 2020 at 16:10

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.