function hook_link

You are here

4.6 core.php hook_link($type, $node = NULL, $teaser = FALSE)
4.7 core.php hook_link($type, $node = NULL, $teaser = FALSE)
5 core.php hook_link($type, $node = NULL, $teaser = FALSE)
6 core.php 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.

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.

For a detailed usage example, see node_example.module.

Related topics

12 functions implement hook_link()

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

blog_link in modules/blog.module
Implementation of hook_link().
book_link in modules/book.module
Implementation of hook_link().
comment_link in modules/comment.module
Implementation of hook_link().
drupal_add_link in includes/common.inc
Add a <link> tag to the page's HEAD.
menu_item_link in includes/menu.inc
Returns the rendered link to a menu item.

... See full list

5 invocations of hook_link()
comment_render in modules/comment.module
node_view in modules/node.module
Generate a display of the given node.
poll_view in modules/poll.module
Implementation of hook_view().
theme_comment_flat_expanded in modules/comment.module
theme_comment_thread_expanded in modules/comment.module

File

developer/hooks/core.php, line 542
These are the hooks that are invoked by the Drupal core.

Code

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;
}