hook_node_view

Versions
7
hook_node_view(stdClass $node, $build_mode)

The node content is being assembled before rendering.

TODO D7 This needs work to clearly explain the different build modes.

The module may add elements to $node->content prior to rendering. This hook will be called after hook_view(). The structure of $node->content is a renderable array as expected by drupal_render().

When $build_mode is 'rss', modules can also add extra RSS elements and namespaces to $node->rss_elements and $node->rss_namespaces respectively for the RSS item generated for this node. For details on how this is used @see node_feed()

See also

taxonomy_node_view()

@see upload_node_view()

See also

comment_node_view()

Parameters

$node The node the action is being performed on.

$build_mode The $build_mode parameter from node_build().

Related topics

Code

modules/node/node.api.php, line 533

<?php
function hook_node_view(stdClass $node, $build_mode) {
  $node->content['my_additional_field'] = array(
    '#value' => $additional_field,
    '#weight' => 10,
    '#theme' => 'mymodule_my_additional_field',
  );
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.