function hook_link_alter
Perform alterations before links on a node or comment 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 or comment, use hook_link() instead.
Parameters
$links: Nested array of links for the node or comment keyed by providing module.
$node: A node object.
$comment: An optional comment object if the links are comment links. If not provided, the links are node links.
See also
Related topics
1 function implements hook_link_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- translation_translation_link_alter in drupal-6.x/
modules/ translation/ translation.module - Implementation of hook_translation_link_alter().
5 invocations of hook_link_alter()
- comment_render in drupal-6.x/
modules/ comment/ comment.module - Renders comment(s).
- node_view in drupal-6.x/
modules/ node/ node.module - Generate a display of the given node.
- taxonomy_link in drupal-6.x/
modules/ taxonomy/ taxonomy.module - Implementation of hook_link().
- theme_comment_flat_expanded in drupal-6.x/
modules/ comment/ comment.module - Theme comment flat expanded view.
- theme_comment_thread_expanded in drupal-6.x/
modules/ comment/ comment.module - Theme comment thread expanded view.
Archivo
- documentation-6.x/
developer/ hooks/ core.php, line 1048 - These are the hooks that are invoked by the Drupal core.
Código
function hook_link_alter(&$links, $node, $comment = NULL) {
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']);
}
}
}