| 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()
1 invocation of hook_entity_info_alter()
File
- modules/
system/ system.api.php, line 264 - 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';
}
Login or register to post comments
Comments
hook_entity_info_alter and template.php (drupal 7)
Hello,
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.
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?
You need to disable/re-enable the module
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!
Cache
You don't need to re-enable the module, clearing the cache is enough.
View modes
http://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