function ctools_entity_field_extra_content_type_render

Render the extra field.

File

plugins/content_types/entity_context/entity_field_extra.inc, line 101

Code

function ctools_entity_field_extra_content_type_render($subtype, $conf, $panel_args, $context) {
  if (empty($context) || empty($context->data)) {
    return;
  }
  // Get a shortcut to the entity.
  $entity = clone $context->data;
  list($entity_type, $field_name) = explode(':', $subtype, 2);
  list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
  $langcode = $GLOBALS['language_content']->language;
  $function = $entity_type . '_view';
  if (in_array($entity_type, array(
    'node',
    'taxonomy_term',
    'user',
  )) && function_exists($function)) {
    // Call known ENTITY_view() to get the extra field.
    $entity->content = $function($entity, $conf['view_mode'], $langcode);
  }
  else {
    // Invoke the view-hook to get the extra field.
    $entity->content = array();
    module_invoke_all($entity_type . '_view', $entity, $conf['view_mode'], $langcode);
    module_invoke_all('entity_view', $entity, $entity_type, $conf['view_mode'], $langcode);
  }
  if (isset($entity->content[$field_name])) {
    // Build the content type block.
    $block = new stdClass();
    $block->module = 'entity_field_extra';
    $block->content = $entity->content[$field_name];
    $block->delta = $id;
    return $block;
  }
}