function node_view

You are here

7 node.module node_view($node, $view_mode = 'full', $langcode = NULL)
4.6 node.module node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
4.7 node.module node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
5 node.module node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
6 node.module node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
8 node.module node_view(NodeInterface $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 or the full form.

$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()
blog_page_last in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
comment_form_add_preview in modules/comment/comment.module
Form builder; Generate and validate a comment preview form.
comment_reply in modules/comment/comment.pages.inc
This function is responsible for generating a comment reply form. There are several cases that have to be handled, including:
node_page_default in modules/node/node.module
Menu callback; Generate a listing of promoted nodes.

... See full list

File

modules/node/node.module, line 1016
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
  $node = (object) $node;

  $node = node_build_content($node, $teaser, $page);

  if ($links) {
    $node->links = module_invoke_all('link', 'node', $node, $teaser);
    drupal_alter('link', $node->links, $node);
  }

  // Set the proper node part, then unset unused $node part so that a bad
  // theme can not open a security hole.
  $content = drupal_render($node->content);
  if ($teaser) {
    $node->teaser = $content;
    unset($node->body);
  }
  else {
    $node->body = $content;
    unset($node->teaser);
  }

  // Allow modules to modify the fully-built node.
  node_invoke_nodeapi($node, 'alter', $teaser, $page);

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

Comments

I was struggling with this for a bit, but it seems that you can still change your node_view build mode to something other than teaser or full by setting the build mode on your node object rather than in the node_view() function.

<?php
$node
->build_mode = 'buildmodename';
print
node_view($node);
?>