Score:1

Add tab for custom entity type on content page

cn flag

I made a custom entity type and I'd like it added to the tabs on the content page seen below.

enter image description here

My custom_entity.links.menu.yml Looks like this

entity.custom_entity.collection:
  title: 'Custom Entities'
  route_name: 'entity.custom_entity.collection'
  description: 'List Custom Entities'
  parent: system.admin_content
entity.custom_entity.add_form:
  title: 'Add Custom Entity'
  route_name: 'entity.custom_entity.collection'
  description: 'Add custom entity'
  parent: entity.custom_entity.collection
custom_entity.admin.structure.settings:
  title: 'Custom Entity Settings'
  description: 'Configure Custom Entity'
  route_name: 'custom_entity.settings'
  parent: system.admin_structure

And it does display the custom entity pages in the admin menu but it does not appear amongst the tabs on the content page. Is there a separate yml file that governs that?

Score:4
in flag

Those tabs called "local tasks." See Providing module-defined local tasks on d.o.

In the simplest case you can define your local tasks in a yaml file:

# example.links.task.yml

example.admin: # The first plugin ID
  route_name: example.admin  
  title: 'Settings'
  base_route: example.admin

example.admin_3rd_party: # The second plugin ID
  route_name: example.admin_3rd_party
  title: 'Third party services'
  base_route: example.admin
  weight: 100

But, it's also possible to define dynamic local tasks.

Per @Matt in the comments, if you want to place this as a tab on the /admin/content page, use base_route: system.admin_content.

Matt avatar
cn flag
Thanks this worked! It's enough info to land on the answer but If you like, you could mention that the base route would be system.admin_content since the question specifically asked about how to make it appear on the content page.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.