hook_view
- Versions
- 4.6 – 4.7
hook_view(&$node, $teaser = FALSE, $page = FALSE)- 5 – 6
hook_view($node,$teaser= FALSE,$page= FALSE)- 7
hook_view($node, $build_mode = 'full')
Display a node.
This is a hook used by node modules. It allows a module to define a custom method of displaying its nodes, usually by displaying extra information particular to that node type.
For a detailed usage example, see node_example.module.
Parameters
$node The node to be displayed, as returned by node_load().
$build_mode Build mode, e.g. 'full', 'teaser', ...
Return value
$node. The passed $node parameter should be modified as necessary and returned so it can be properly presented. Nodes are prepared for display by assembling a structured array, formatted as in the Form API, in $node->content. As with Form API arrays, the #weight property can be used to control the relative positions of added elements. After this hook is invoked, node_build() calls field_attach_view() to add field views to $node->content, and then invokes hook_node_view() and hook_node_build_alter(), so if you want to affect the final view of the node, you might consider implementing one of these hooks instead.
Related topics
Code
modules/node/node.api.php, line 987
<?php
function hook_view($node, $build_mode = 'full') {
if ((bool)menu_get_object()) {
$breadcrumb = array();
$breadcrumb[] = array('path' => 'example', 'title' => t('example'));
$breadcrumb[] = array('path' => 'example/' . $node->field1,
'title' => t('%category', array('%category' => $node->field1)));
$breadcrumb[] = array('path' => 'node/' . $node->nid);
menu_set_location($breadcrumb);
}
$node->content['myfield'] = array(
'#value' => theme('mymodule_myfield', $node->myfield),
'#weight' => 1,
);
return $node;
}
?>Login or register to post comments 