node_view

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

Generate an array for rendering the given node.

Parameters

$node A node object.

$view_mode View mode, e.g. 'full', 'teaser'...

$langcode (optional) A language code to use for rendering. Defaults to the global content language of the current request.

Return value

An array as expected by drupal_render().

▾ 11 functions call node_view()

book_node_export in modules/book/book.module
Generates printer-friendly HTML for a node.
comment_preview in modules/comment/comment.module
Generate a comment preview.
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:
FieldUIManageDisplayTestCase::assertNodeViewTextHelper in modules/field_ui/field_ui.test
Helper for assertNodeViewText and assertNodeViewNoText.
node_example_page in examples/node_example/node_example.module
Callback that builds our content and returns it to the browser.
node_feed in modules/node/node.module
Generates and prints an RSS feed.
node_search_execute in modules/node/node.module
Implements hook_search_execute().
node_unpublish_by_keyword_action in modules/node/node.module
Unpublishes a node containing certain keywords.
node_view_multiple in modules/node/node.module
Construct a drupal_render() style array from an array of loaded nodes.
theme_node_preview in modules/node/node.pages.inc
Returns HTML for a node preview for display during node creation and editing.
_node_index_node in modules/node/node.module
Index a single node.

Code

modules/node/node.module, line 1279

<?php
function node_view($node, $view_mode = 'full', $langcode = NULL) {
  if (!isset($langcode)) {
    $langcode = $GLOBALS['language_content']->language;
  }

  // Populate $node->content with a render() array.
  node_build_content($node, $view_mode, $langcode);

  $build = $node->content;
  // We don't need duplicate rendering info in node->content.
  unset($node->content);

  $build += array(
    '#theme' => 'node', 
    '#node' => $node, 
    '#view_mode' => $view_mode, 
    '#language' => $langcode,
  );

  // Add contextual links for this node, except when the node is already being
  // displayed on its own page. Modules may alter this behavior (for example,
  // to restrict contextual links to certain view modes) by implementing
  // hook_node_view_alter().
  if (!empty($node->nid) && !($view_mode == 'full' && node_is_page($node))) {
    $build['#contextual_links']['node'] = array('node', array($node->nid));
  }

  // Allow modules to modify the structured node.
  $type = 'node';
  drupal_alter(array('node_view', 'entity_view'), $build, $type);

  return $build;
}
?>