function nat_link_alter in Node Auto Term [NAT] 5
Same name and namespace in other branches
- 6.2 nat.module \nat_link_alter()
- 6 nat.module \nat_link_alter()
Implementation of hook_link_alter().
File
- ./nat.module, line 176 
- 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(&$node, &$links) {
  $nat_config = _nat_variable_get();
  if (isset($nat_config['node_links'][$node->type])) {
    foreach ($links as $module => $link) {
      // $link['title'] will be empty during node previews at which point
      // taxonomy links do not work.
      if (strpos($module, 'taxonomy_term') !== FALSE && $link['title']) {
        $tids = array(
          str_replace('taxonomy/term/', '', $link['href']),
        );
        $nids = array_keys(nat_get_nids($tids, FALSE));
        if (!empty($nids)) {
          // Link back to the NAT node and not the taxonomy term page.
          $links[$module]['href'] = "node/{$nids[0]}";
        }
      }
    }
  }
}