Skip to content

5. Adding administrative links

To provide a usable and integrated administration experience the different pages need to be connected and enriched with Drupal’s standard administrative links.

Section titled “5.1. Add a menu link for the event listing”

For the event listing to show up in the toolbar menu under Content, we need to provide a menu link for it.

  • Add an event.links.menu.yml file in the event module directory with the following:

    entity.event.collection:
      title: 'Events'
      route_name: entity.event.collection
      parent: system.admin_content
  • Rebuild caches

    Run drush cache:rebuild

  • Verify that there is an Events link in the toolbar menu.

    Note that there is no Event local task on /admin/content.

5.2. Add a local task for the event listing

Section titled “5.2. Add a local task for the event listing”
  • Add an event.links.task.yml file in the event module directory with the following:

    entity.event.collection:
      title: 'Events'
      route_name: entity.event.collection
      base_route: system.admin_content
  • Rebuild caches

    Run drush cache:rebuild

  • Verify that the Events local task appears on /admin/content

5.3. Add local tasks for the edit and delete forms

Section titled “5.3. Add local tasks for the edit and delete forms”
  • Add the following to event.links.task.yml:

    entity.event.canonical:
      title: 'View'
      route_name: entity.event.canonical
      base_route: entity.event.canonical
    entity.event.edit_form:
      title: 'Edit'
      route_name: entity.event.edit_form
      base_route: entity.event.canonical
    entity.event.delete_form:
      title: 'Delete'
      route_name: entity.event.delete_form
      base_route: entity.event.canonical
  • Rebuild caches

    Run drush cache:rebuild

  • Visit /events/2

    Verify that View, Edit and Delete local tasks are shown.