function panels_node_view in Panels 6.3
Same name and namespace in other branches
- 5.2 panels_node/panels_node.module \panels_node_view()
 - 6.2 panels_node/panels_node.module \panels_node_view()
 
Implementation of hook_view().
File
- panels_node/
panels_node.module, line 292  - panels_node.module
 
Code
function panels_node_view($node, $teaser = FALSE, $page = FALSE) {
  static $rendering = array();
  // Prevent loops if someone foolishly puts the node inside itself:
  if (!empty($rendering[$node->nid])) {
    return $node;
  }
  $rendering[$node->nid] = TRUE;
  ctools_include('plugins', 'panels');
  if ($teaser) {
    // Do the standard view for teaser.
    $node = node_prepare($node, $teaser);
    // Because our teasier is never the same as our content, *always* provide
    // the read more flag.
    $node->readmore = TRUE;
  }
  else {
    if (!empty($node->panels_node['did'])) {
      $display = panels_load_display($node->panels_node['did']);
      $display->css_id = $node->panels_node['css_id'];
      // TODO: Find a way to make sure this can't node_view.
      $display->context = panels_node_get_context($node);
      $renderer = panels_get_renderer($node->panels_node['pipeline'], $display);
      $node->content['body'] = array(
        '#value' => panels_render_display($display, $renderer),
        '#weight' => 0,
      );
    }
  }
  unset($rendering[$node->nid]);
  return $node;
}