function hook_entity_view

hook_entity_view($entity, $type, $view_mode, $langcode)

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

hook_entity_view_alter()

hook_comment_view()

hook_node_view()

hook_user_view()

Related topics

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',
  );
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_entity_view/7.x