2

Using Drupal 8, I'm trying to modify the page at "/admin/structure/types" .This page is not a form (instead it is an entity list), so it cannot be modified with hook_form_alter.

_entity_list: The value is entity_type. Provides a list of entities using the EntityListController of the respective entity. E.g. _entity_list: view_mode returns the render array of a list of view modes.

Which hook can I use to modify an entity list ?

I have tried

  • mymodule_structure_types_prepare_form

  • mymodule_structure_prepare_form

and none of those is triggered.

2
  • Why is view-mode tagged for this? Or inline-entity-form? – Kevin Mar 13 '17 at 15:38
  • sorry I untagged it – Diana Mar 13 '17 at 15:39
6

see Can you change the list builder class used by an entity?

Using hook_entity_type_alter() you can override the list builder for nodes.

You can add a custom NodeListBuilder in your module that extends or replaces /core/modules/node/src/NodeListBuilder.php

This class is pretty simple, so it should be easy to add or remove rows to the table displayed.

3

Inside \core\modules\node\node.routing.yml you can see that the path "admin/structure/types" is having defaults: _entity_list

From https://www.drupal.org/docs/8/api/routing-system/structure-of-routes I can see that:

_entity_list: The value is entity_type. Provides a list of entities using the EntityListController of the respective entity. E.g. _entity_list: view_mode returns the render array of a list of view modes.

So, the question would be to modify the output of this EntityListController.

Update: Apparently this has already been answered , as other people suggested.

I just found this. It might be helpful as a complete example. How do I add a column to the table shown in the vocabulary listing page?

2

I solved this by using hook_clone_entity_load( $entities, $type), and when the type==block I am on that page

1
  • Out of curiosity, would you share the code.. ? – Oleg Videnov Mar 14 '17 at 12:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.