function hook_entity_prepare_view

Act on entities as they are being prepared for view.

Allows you to operate on multiple entities as they are being prepared for view. Only use this if attaching the data during the entity loading phase is not appropriate, for example when attaching other 'entity' style objects.

Parameters

array $entities: The entities keyed by entity ID.

string $entity_type: The type of entities being viewed (i.e. node, user, comment).

Related topics

1 invocation of hook_entity_prepare_view()

File

drupal/core/includes/entity.api.php, line 253
Hooks provided the Entity module.

Code

function hook_entity_prepare_view($entities, $entity_type) {

  // Load a specific node into the user object for later theming.
  if (!empty($entities) && $entity_type == 'user') {
    $nodes = mymodule_get_user_nodes(array_keys($entities));
    foreach ($entities as $uid => $entity) {
      $entity->user_node = $nodes[$uid];
    }
  }
}