hook_link_alter

developer/hooks/core.php, line 962

Versions
5
hook_link_alter(&$node, &$links)
6
hook_link_alter(&$links, $node)
7
hook_link_alter(array &$links, $node)

Perform alterations before links on a node are rendered. One popular use of this hook is to modify/remove links from other modules. If you want to add a link to the links section of a node, use hook_link instead.

Parameters

$links Nested array of links for the node keyed by providing module.

$node A node object that contains the links.

Return value

None.

Related topics

Code

<?php
function hook_link_alter(&$links, $node) {
  foreach ($links as $module => $link) {
    if (strstr($module, 'taxonomy_term')) {
      // Link back to the forum and not the taxonomy term page
      $links[$module]['href'] = str_replace('taxonomy/term', 'forum', $link['href']);
    }
  }
}
?>
 
 

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.