Drupal hook: hook_view
The full view of a node including all the information associated with the nodes like author, node posted date, file attached to the node and any other data that are associated by other custom modules is managed by hook_view. The main goal and use of the hook_view is to allow the node modules to add extra information and manage those extra information to display when viewing the node. Nodes can have tease view as well as page view. On teaser view, only some of the information associated with the node is displayed; we can say its an overview of the node. On page view, all the information associated with the node is displayed.
<?php
/**
* Implementation of hook_view
* @param $node
* @param $teaser
* @param $page
* @return unknown_type
* @author Drupal Developer
*/
function codelet_view($node, $teaser = FALSE, $page = FALSE) {
if ($page) {
$sn__code_book = _get_parent($node->nid);
$sn__parent_title = _get_node_title($sn__code_book);
$sn__codelet_title = _get_node_title($node->nid);
$breadcrumb = array();
$breadcrumb[] = l(t("Home"), $base_url);
$breadcrumb[] = l($sn__parent_title, drupal_get_path_alias("node/". $sn__code_book));
$breadcrumb[] = $sn__codelet_title;
drupal_set_breadcrumb($breadcrumb);
}
$node = node_prepare($node, $teaser);
$ss__codelet_code = theme_get_code($node->nid);
$node->content['codebook'] = array(
'#value' => t("in") ." ". l($sn__parent_title, drupal_get_path_alias("node/". $sn__code_book)),
'#weight' => -10,
);
$node->content['code'] = array(
'#value' => $ss__codelet_code,
'#weight' => 49,
);
return $node;
}
//needless to say, this is the code from one of the modules used on Drupal Developer.
?>- 1550 reads
-
- Send feedback



Search
Sitestats
Recent comments
- Create a separate .js file
1 week 6 days ago - Thanks for your reply
1 week 6 days ago - Jquery and nice menus
1 week 6 days ago - Image Menu
2 weeks 3 days ago - Image menu
2 weeks 4 days ago - Its cool to have a status!
34 weeks 6 days ago


