hook_link

Versions
4.6 – 5
hook_link($type, $node = NULL, $teaser = FALSE)
6
hook_link($type, $object, $teaser = FALSE)

Define internal Drupal links.

This hook enables modules to add links to many parts of Drupal. Links may be added in nodes or in the navigation block, for example.

For a detailed usage example, see node_example.module.

Parameters

$type An identifier declaring what kind of link is being requested. Possible values:

  • node: Links to be placed below a node being viewed.
  • comment: Links to be placed below a comment being viewed.

$node A node object passed in case of node links.

$teaser In case of node link: a 0/1 flag depending on whether the node is displayed with its teaser or its full form (on a node/nid page)

Return value

An array of the requested links.

Related topics

Code

developer/hooks/core.php, line 459

<?php
function hook_link($type, $node = NULL, $teaser = FALSE) {
  $links = array();

  if ($type == 'node' && $node->type == 'book') {
    if (book_access('update', $node)) {
      $links[] = l(t('edit this page'), "node/$node->nid/edit",
        array('title' => t('Suggest an update for this book page.')));
    }
    if (!$teaser) {
      $links[] = l(t('printer-friendly version'), "book/print/$node->nid",
        array('title' => t('Show a printer-friendly version of this book page
        and its sub-pages.')));
    }
  }

  return $links;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.