hook_link_alter

Definition

hook_link_alter(&$node, &$links)
developer/hooks/core.php, line 646

Description

Perform alterations before links on a node are rendered. One popular use of this hook is to add/delete links from other modules.

Parameters

$node A node object for editing links on

$links Nested array of links for the node

Return value

None.

Related topics

Namesort iconDescription
HooksAllow modules to interact with the Drupal core.

Code

<?php
function hook_link_alter(&$node, &$links) {
  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.