You are here

function panelizer_panelizer_task_render in Panelizer 7.3

Same name and namespace in other branches
  1. 6 plugins/task_handlers/panelizer_node.inc \panelizer_panelizer_task_render()
  2. 7 plugins/task_handlers/panelizer_node.inc \panelizer_panelizer_task_render()
  3. 7.2 plugins/task_handlers/panelizer_node.inc \panelizer_panelizer_task_render()

Render a entity that has been panelized.

1 string reference to 'panelizer_panelizer_task_render'
panelizer_node.inc in plugins/task_handlers/panelizer_node.inc
This is the task handler plugin to handle an entity view. NOTE: This is named panelizer_node for historical reasons. It is too much of a pain to change the name of a task handler. This panelizes any entity not just a node.

File

plugins/task_handlers/panelizer_node.inc, line 285
This is the task handler plugin to handle an entity view. NOTE: This is named panelizer_node for historical reasons. It is too much of a pain to change the name of a task handler. This panelizes any entity not just a node.

Code

function panelizer_panelizer_task_render($handler, $base_contexts, $args, $test = TRUE) {

  // Get the context this is viewing; figure out what entity it is and load
  // the right plugin.
  ctools_include('context');
  $context = _panelizer_panelizer_task_get_context($handler, $base_contexts);
  if (!$context) {
    return FALSE;
  }
  if (empty($context->data->panelizer['page_manager'])) {
    return FALSE;
  }
  $panelizer = $context->data->panelizer['page_manager'];

  // One of these two will always be set.
  $entity_type = !empty($panelizer->entity_type) ? $panelizer->entity_type : $panelizer->panelizer_type;
  $address = implode('::', array(
    'page_manager',
    $handler->task,
    $handler->subtask,
    $handler->name,
    implode('..', $args),
  ));
  if ($entity_handler = panelizer_entity_plugin_get_handler($entity_type)) {
    $extra_contexts = _panelizer_panelizer_task_get_extra_contexts($handler, $base_contexts);
    $info = $entity_handler
      ->render_entity($context->data, 'page_manager', NULL, $args, $address, $extra_contexts);

    // Add body element classes, appending to the existing value.
    $panel_body_css =& drupal_static('panel_body_css', array());
    if (!empty($info['classes_array'])) {
      $panel_body_css += array(
        'body_classes_to_add' => '',
      );
      $panel_body_css['body_classes_to_add'] = trim($panel_body_css['body_classes_to_add'] . ' ' . implode(' ', $info['classes_array']));
    }
    return $info;
  }
}