node_view

Definition

node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
modules/node.module, line 481

Description

Generate a display of the given node.

Parameters

$node A node array or node object.

$teaser Whether to display only the teaser for the node.

$page Whether the node is being displayed by itself as a page.

$links Whether or not to display node links. Links are omitted for node previews.

Return value

An HTML representation of the themed node.

Code

<?php
function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
  $node = array2object($node);

  // Remove the delimiter (if any) that separates the teaser from the body.
  // TODO: this strips legitimate uses of '<!--break-->' also.
  $node->body = str_replace('<!--break-->', '', $node->body);

  // The 'view' hook can be implemented to overwrite the default function
  // to display nodes.
  if (node_hook($node, 'view')) {
    node_invoke($node, 'view', $teaser, $page);
  }
  else {
    $node = node_prepare($node, $teaser);
  }
  // Allow modules to change $node->body before viewing.
  node_invoke_nodeapi($node, 'view', $teaser, $page);
  if ($links) {
    $node->links = module_invoke_all('link', 'node', $node, !$page);
  }
  // unset unused $node part so that a bad theme can not open a security hole
  if ($teaser) {
    unset($node->body);
  }
  else {
    unset($node->teaser);
  }

  return theme('node', $node, $teaser, $page);
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.