Same name and namespace in other branches
  1. 4.6.x developer/hooks/node.php \hook_view()
  2. 5.x developer/hooks/node.php \hook_view()
  3. 6.x developer/hooks/node.php \hook_view()
  4. 7.x modules/node/node.api.php \hook_view()

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.

Parameters

&$node: The node to be displayed.

$teaser: Whether we are to generate a "teaser" or summary of the node, rather than display the whole thing.

$page: Whether the node is being displayed as a standalone page. If this is TRUE, the node title should not be displayed, as it will be printed automatically by the theme system. Also, the module may choose to alter the default breadcrumb trail in this case.

Return value

None. The passed-by-reference $node parameter should be modified as necessary so it can be properly presented by theme('node', $node). This means, for instance, that content should be passed through the filter system by calling check_output() on appropriate fields or by sending the node through node_prepare().

For a detailed usage example, see node_example.module.

Related topics

12 functions implement hook_view()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

aggregator_view in modules/aggregator.module
blog_view in modules/blog.module
Implementation of hook_view().
book_view in modules/book.module
Implementation of hook_view().
fileupload_view in developer/examples/fileupload.module
Implementation of hook_view.
forum_view in modules/forum.module
Implementation of hook_view().

... See full list

File

developer/hooks/node.php, line 341
These hooks are defined by node modules, modules that define a new kind of node.

Code

function hook_view(&$node, $teaser = FALSE, $page = FALSE) {
  if ($page) {
    $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 = node_prepare($node, $teaser);
}