You are here

function panels_panel_node_view_render in Panels 6.2

Attempt to render a node.

We must first check to ensure the node is of a type we're allowed to render. If not, decline to render it by returning NULL.

1 string reference to 'panels_panel_node_view_render'
panels_panel_node_view_delegator_task_handlers in plugins/task_handlers/panel_node_view.inc

File

plugins/task_handlers/panel_node_view.inc, line 104

Code

function panels_panel_node_view_render($handler, $node) {
  if (empty($handler->conf['type'][$node->type])) {
    return;
  }

  // Load the node into a context
  panels_load_include('plugins');
  $context = panels_context_create('node', $node);
  $context->identifier = t('Node being viewed');
  $context->keyword = 'node';

  // Load the display
  $display = drupal_clone($handler->conf['display']);
  $display->context = array(
    'panel-node' => $context,
  );
  $display->css_id = $handler->conf['css_id'];

  // Check to see if there is any CSS.
  if ($handler->conf['css_cache']) {
    if (!file_exists($handler->conf['css_cache'])) {

      // This will force the task handler to re-cache the CSS and save the filename:
      delegator_save_task_handler($handler);
    }
    dsm("Addning: " . $handler->conf['css_cache']);
    drupal_add_css($handler->conf['css_cache']);
  }

  // Since we're not using node_show() we need to emulate what it used to do.
  // Update the history table, stating that this user viewed this node.
  node_tag_new($node->nid);
  $output = panels_render_display($display);
  if (!empty($handler->conf['no_blocks'])) {
    print theme('page', $output, FALSE);

    // We return TRUE to let it know we handled this but have already
    // handled the output rendering ourselves.
    return TRUE;
  }
  return $output;
}