function entity_entity_view_content_type_render

7.x entity_view.inc entity_entity_view_content_type_render($entity_type, $conf, $panel_args, $context)

Implements hook_PLUGIN_content_type_render().

Ctools requires us to return a block.

See also

ctools_content_render()

File

entity/ctools/content_types/entity_view.inc, line 107
Content type plugin to expose rendered entities, view mode configuration still available.

Code

function entity_entity_view_content_type_render($entity_type, $conf, $panel_args, $context) {
  if ($context->empty) {
    return;
  }
  $block = new stdClass();
  $block->module = 'entity';
  $block->delta = $entity_type . '-' . str_replace('-', '_', $conf['view_mode']);

  $entity_id = $context->argument;
  $entity = entity_load_single($entity_type, $entity_id);
  $block->content = entity_view($entity_type, array($entity_id => $entity), $conf['view_mode']);
  return $block;
}