node_view

  1. drupal
    1. 4.7
    2. 5 node.module
    3. 6 node.module
    4. 7 node.module
Versions
4.7 – 6 node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
7 node_view($node, $view_mode = 'full', $langcode = NULL)

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 functions call 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
node_page_default in modules/node.module
Generate a listing of promoted nodes.
node_show in modules/node.module
Generate a page displaying a single node, along with its comments.
taxonomy_render_nodes in modules/taxonomy.module
Accepts the result of a pager_query() call, such as that performed by taxonomy_select_nodes(), and formats each node along with a pager.
theme_node_preview in modules/node.module
Display a node preview for display during node creation and editing.

Code

modules/node.module, line 531

<?php
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);
}
?>