function entity_prepare_view

cis7 entity_prepare_view($entity_type, $entities, $langcode = NULL)
cle7 entity_prepare_view($entity_type, $entities, $langcode = NULL)
elmsmedia7 entity_prepare_view($entity_type, $entities, $langcode = NULL)
icor7 entity_prepare_view($entity_type, $entities, $langcode = NULL)
meedjum_blog7 entity_prepare_view($entity_type, $entities, $langcode = NULL)
mooc7 entity_prepare_view($entity_type, $entities, $langcode = NULL)

Invoke hook_entity_prepare_view().

If adding a new entity similar to nodes, comments or users, you should invoke this function during the ENTITY_build_content() or ENTITY_view_multiple() phases of rendering to allow other modules to alter the objects during this phase. This is needed for situations where information needs to be loaded outside of ENTITY_load() - particularly when loading entities into one another - i.e. a user object into a node, due to the potential for unwanted side-effects such as caching and infinite recursion. By convention, entity_prepare_view() is called after field_attach_prepare_view() to allow entity level hooks to act on content loaded by field API.


$entity_type: The type of entity, i.e. 'node', 'user'.

$entities: The entity objects which are being prepared for view, keyed by object ID.

$langcode: (optional) A language code to be used for rendering. Defaults to the global content language of the current request.

See also


14 calls to entity_prepare_view()
accessibility_test_render in sites/all/modules/ulmus/accessibility/accessibility.module
comment_build_content in modules/comment/comment.module
Builds a structured array representing the comment's content.
comment_view_multiple in modules/comment/comment.module
Construct a drupal_render() style array from an array of loaded comments.
ctools_node_content_render_node in sites/all/modules/ulmus/ctools/plugins/content_types/node_context/
EntityAPIController::view in sites/all/modules/ulmus/entity/includes/
Implements EntityAPIControllerInterface.

... See full list


includes/, line 7866
Common functions that many Drupal modules will need to reference.


function entity_prepare_view($entity_type, $entities, $langcode = NULL) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;

  // To ensure hooks are only run once per entity, check for an
  // entity_view_prepared flag and only process items without it.
  // @todo: resolve this more generally for both entity and field level hooks.
  $prepare = array();
  foreach ($entities as $id => $entity) {
    if (empty($entity->entity_view_prepared)) {
      // Add this entity to the items to be prepared.
      $prepare[$id] = $entity;

      // Mark this item as prepared.
      $entity->entity_view_prepared = TRUE;

  if (!empty($prepare)) {
    module_invoke_all('entity_prepare_view', $prepare, $entity_type, $langcode);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.