function hook_entity_view in Drupal 7
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_view()
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_view()
- 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_view()
Act on entities being assembled before rendering.
Parameters
$entity: The entity object.
$type: The type of entity being rendered (i.e. node, user, comment).
$view_mode: The view mode the entity is rendered in.
$langcode: The language code used for rendering.
The module may add elements to $entity->content prior to rendering. The structure of $entity->content is a renderable array as expected by drupal_render().
See also
Related topics
1 function implements hook_entity_view()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- taxonomy_test_entity_view in modules/
simpletest/ tests/ taxonomy_test.module - Implements hook_entity_view().
4 invocations of hook_entity_view()
- comment_build_content in modules/
comment/ comment.module - Builds a structured array representing the comment's content.
- node_build_content in modules/
node/ node.module - Builds a structured array representing the node's content.
- taxonomy_term_build_content in modules/
taxonomy/ taxonomy.module - Builds a structured array representing the term's content.
- user_build_content in modules/
user/ user.module - Builds a structured array representing the profile content.
File
- modules/
system/ system.api.php, line 428 - Hooks provided by Drupal core and the System module.
Code
function hook_entity_view($entity, $type, $view_mode, $langcode) {
$entity->content['my_additional_field'] = array(
'#markup' => $additional_field,
'#weight' => 10,
'#theme' => 'mymodule_my_additional_field',
);
}