| Versionen | |
|---|---|
| drupal6 | hook_view($node, $teaser = FALSE, |
| drupal7 | hook_view($node, $teaser = FALSE) |
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.
$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.
$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 in $node->content, rather than directly manipulating $node->body and $node->teaser. The format of this array is the same used by the Forms API. As with FormAPI arrays, the #weight property can be used to control the relative positions of added elements. If for some reason you need to change the body or teaser returned by node_prepare(), you can modify $node->content['body']['#value']. Note that this will be the un-rendered content. To modify the rendered output, see hook_node($op = 'alter').
For a detailed usage example, see node_example.module.
modules/
<?php
function hook_view($node, $teaser = FALSE) {
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 = node_prepare($node, $teaser);
$node->content['myfield'] = array(
'#value' => theme('mymodule_myfield', $node->myfield),
'#weight' => 1,
);
return $node;
}
?>
Kommentare
Kommentar hinzufügen