7.x system.api.php hook_entity_info_alter(&$entity_info)

Alter the entity info.

Modules may implement this hook to alter the information that defines an entity. All properties that are available in hook_entity_info() can be altered here.


$entity_info: The entity info array, keyed by entity name.

See also


Related topics

5 functions implement hook_entity_info_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

book_entity_info_alter in modules/book/book.module
Implements hook_entity_info_alter().
field_test_entity_info_alter in modules/field/tests/field_test.entity.inc
Implements hook_entity_info_alter().
forum_entity_info_alter in modules/forum/forum.module
Implements hook_entity_info_alter().
locale_entity_info_alter in modules/locale/locale.module
Implements hook_entity_info_alter().
rdf_entity_info_alter in modules/rdf/rdf.module
Implements hook_entity_info_alter().


modules/system/system.api.php, line 285
Hooks provided by Drupal core and the System module.


function hook_entity_info_alter(&$entity_info) {

  // Set the controller class for nodes to an alternate implementation of the
  // DrupalEntityController interface.
  $entity_info['node']['controller class'] = 'MyCustomNodeController';


flyzi’s picture


This hook doesn't work in my template.php (my custom theme)

I want to do this :

function mythemename_entity_info_alter(&$entity_info){
  $entity_info['node']['view modes']['taxonomy_listing'] = array(
    'label' => t('Taxonomy listing'),
    'custom settings' => TRUE,

What is the solution ?

bensey’s picture

Firstly you need to include this in a custom module, not template.php, eg.
function custommodule_entity_info_alter(&$entity_info){

Initially I couldn't get this working either, once the module was enabled the view mode was there enabled in the checkbox list, but was missing the secondary tab/button to customise it.

Cleared all caches etc., no luck.

As I wanted to only use this mode in a ubercart product, I tried changing the entity 'node' to 'product' in the code. My view mode tab now appeared, but errors abounded.

Switched it back to 'node' and tab stayed there, and now works fine with no errors...

Can anyone explain this? Is it something to do with the way that ubercart declares/creates the product content type in the product module?

paul2’s picture

I found that disabling the module that implements hook_entity_info_alter(), then re-enabling it, allows the tab for the newly created view mode to appear on the Manage Display page.

Hope this helps someone!

grandpalacko’s picture

You don't need to re-enable the module, clearing the cache is enough.

ergophobe’s picture

Actually, I was having a similar issue and disabling and re-enabling the module did the trick, whereas numerous cache clears did not.

Marko B’s picture

Actually for me registry rebuild is the one that worked, even unistalling and reinstalling didnt help.

hodba’s picture

For me, running update.php resolved the problem.

NancyDru’s picture

dpi’s picture

alberto56’s picture

If you're using the Entity contrib module, this issue might be preventing your changes to certain properties from taking effect. In contains a patch which I successfully applied.

damondt’s picture

I couldn't get the display to show up until I set the 'custom settings' key in the example above to null rather than TRUE. I tried it because that's how most of the preexisting displays were doing it.

function hook_entity_info_alter(&$entity_info){
$entity_info['node']['view modes']['new_display_machine_name'] = array(
'label' => t('New Display Name'),
'custom settings' => '',