You are here

function panels_node_hook_view in Panels 7.3

Implementation of hook_view().

File

panels_node/panels_node.module, line 300
panels_node.module

Code

function panels_node_hook_view($node, $view_mode) {
  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 ($view_mode == '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);
      $display->cache_key = 'panels_node:' . $node->nid;
      $renderer = panels_get_renderer($node->panels_node['pipeline'], $display);
      $node->content['body'] = array(
        '#markup' => panels_render_display($display, $renderer),
        '#weight' => 0,
      );
    }
  }
  unset($rendering[$node->nid]);
  return $node;
}