node_view

5 node.module node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
6 node.module node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE)
7 node.module node_view($node, $view_mode = 'full', $langcode = NULL)
8 node.module node_view(Node $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 calls to node_view()

4 string references to 'node_view'

File

modules/node/node.module, line 1277
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, $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;
}

Comments

The $links parameter has been

The $links parameter has been removed in 7.

To disable links, looks like need to do something akin to below (untested)

<?php
$build
= node_view( ...);
$build['links']['#access'] = FALSE;
?>

Login or register to post comments