--- nat.module.orig 2009-03-01 02:27:51.000000000 -0500 +++ nat.module 2009-04-27 15:47:01.000000000 -0400 @@ -60,6 +60,13 @@ 'type' => MENU_LOCAL_TASK, 'file' => 'nat.admin.inc' ); + $items['taxonomy/term/%/nat'] = array( + 'title' => 'NAT for term', + 'page callback' => 'nat_goto_node', + 'page arguments' => array(2), + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -214,11 +221,9 @@ // $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]"; + $path = nat_get_node_path_for_tid(str_replace('taxonomy/term/', '', $link['href'])); + if ($path) { + $links[$module]['href'] = $path; } } } @@ -238,6 +243,19 @@ } /** + * Menu callback: Redirect to associated node. + */ +function nat_goto_node($tid) { + $path = nat_get_node_path_for_tid($tid); + if ($path) { + drupal_goto($path); + } + else { + return "taxonomy/term/$tid"; + } +} + +/** * Gets terms associated with a node. * * @param $nid @@ -304,6 +322,22 @@ } /** + * Retrieve the NAT node path for the provided term ID. + * + * @param $tid + * The term ID whose associated node is to be retrieved. + * @return + * The path to the associated node. + */ +function nat_get_node_path_for_tid($tid) { + $nids = array_keys(nat_get_nids(array($tid), FALSE)); + if (!empty($nids)) { + return "node/$nids[0]"; + } + return FALSE; +} + +/** * Retrieve all all the children of a node via its NAT association. * Note: taxonomy_select_nodes is a rather resource hungry function. *