You are here

function node_view in Drupal 4

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_view()
  2. 5 modules/node/node.module \node_view()
  3. 6 modules/node/node.module \node_view()
  4. 7 modules/node/node.module \node_view()

Generate a display of the given node.

Parameters

$node: A node array or node object.

$teaser: Whether to display the teaser only, as on the main page.

$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.

9 calls to node_view()
archive_page in modules/archive.module
Menu callback; lists all nodes posted on a given date.
blog_page_last in modules/blog.module
Displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog.module
Displays a Drupal page containing recent blog entries of a given user.
comment_form_add_preview in modules/comment.module
comment_reply in modules/comment.module

... See full list

File

modules/node.module, line 530
The core that allows content to be submitted to the site.

Code

function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
  $node = (object) $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);
  if ($node->log != '' && !$teaser && $node->moderate) {
    $node->body .= '<div class="log"><div class="title">' . t('Log') . ':</div>' . filter_xss($node->log) . '</div>';
  }

  // 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);
}