function nat_link_alter in Node Auto Term [NAT] 6.2
Same name and namespace in other branches
- 5 nat.module \nat_link_alter()
- 6 nat.module \nat_link_alter()
Implementation of hook_link_alter().
File
- ./
nat.module, line 213 - NAT - node auto term - is a helper module that automatically creates a term using the same title as a node.
Code
function nat_link_alter(&$links, $node) {
$nat_config = _nat_variable_get();
if (isset($nat_config['node_links'][$node->type])) {
foreach ($links as $module => $link) {
// Extract the term ID from the module indicator.
$tid = str_replace('taxonomy_term_', '', $module, $count);
// $link['title'] will be empty during node previews at which point
// taxonomy links do not work.
if ($count && $link['title']) {
$nids = array_keys(nat_get_nids(array(
$tid,
), FALSE));
if (!empty($nids)) {
// Link back to the NAT node and not the taxonomy term page.
$links[$module]['href'] = "node/{$nids[0]}";
}
}
}
}
}