function node_view
Same name in other branches
- 8.9.x core/modules/node/node.module \node_view()
Generates 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().
14 calls to 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 - Asserts that a string is (not) found in the rendered nodein a view mode.
- ImageFieldDefaultImagesTestCase::testDefaultImages in modules/
image/ image.test - Tests CRUD for fields and fields instances with default images.
1 string reference to 'node_view'
- trigger_node_view in modules/
trigger/ trigger.module - Implements hook_node_view().
File
-
modules/
node/ node.module, line 1330
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.