| 7 system.api.php | hook_entity_info_alter(&$entity_info) |
| 8 entity.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.
Parameters
$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().
File
- modules/
system/ system.api.php, line 285 - Hooks provided by Drupal core and the System module.
Code
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';
}
Comments
hook_entity_info_alter and template.php (drupal 7)
PermalinkHello,
This hook doesn't work in my template.php (my custom theme)
I want to do this :
http://www.braahm.be/posts/tuning-taxonomy-pages-page-manager-panels-vie...
<?phpfunction 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 ?
You need to add that in a custom module, not in template.php.
PermalinkFirstly 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?
You need to disable/re-enable the module
PermalinkI 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!
Cache
PermalinkYou don't need to re-enable the module, clearing the cache is enough.
There's a module for that...
Permalinkhttp://drupal.org/project/entity_view_mode
View modes
Permalinkhttp://denver2012.drupal.org/program/sessions/view-modes-many-faces-your...
examples/links
http://bit.ly/view-modes currently points to:
http://www.treehouseagency.com/learn/view-modes/extra-fields