• Avail guidance to develop Drupal modules & Drupal themes
  • Share and get review of your code
  • Get Access to free CodeBooks and ThemeBooks
  • Drupal 5, 6 and 7 covered

About bhavinhjoshi

Drupal hook: hook_view

Printer-friendly versionSend to a DeveloperPDF version
3
0

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.
?>

Syndicate content

Sitestats

Recent comments

rss-top-right.png
toolbar powered by www.iconcy.com