--- nat.module	7 May 2007 06:14:40 -0000	1.14.2.7
+++ nat.module	31 May 2007 16:39:34 -0000
@@ -159,6 +159,12 @@
       '#default_value' => isset($nat_config['delete'][$type]) ? $nat_config['delete'][$type] : 0,
       '#parents' => array('delete', $type)
     );
+    $form['nat_'. $type]['nodelink_'. $type] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Term links point to the associated node, not to the taxonomy page.'),
+      '#default_value' => isset($nat_config['nodelink'][$type]) ? $nat_config['nodelink'][$type] : 0,
+      '#parents' => array('nodelink', $type)
+    );
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
@@ -173,6 +179,7 @@
 
   $form_values['body'] = array_filter($form_values['body']);
   $form_values['delete'] = array_filter($form_values['delete']);
+  $form_values['nodelink'] = array_filter($form_values['nodelink']);
 
   variable_set('nat_config', $form_values);
 
@@ -382,6 +389,26 @@
 }
 
 /**
+ * Implementation of hook_nodeapi().
+ */
+function nat_link_alter(&$node, &$links) {
+  $nat_config = variable_get('nat_config', array());
+  if (isset($nat_config['nodelink'][$node->type])) {
+    foreach ($links AS $module => $link) {
+      if (strstr($module, 'taxonomy_term')) {
+        $tids = array();
+        $tids[] = str_replace('taxonomy/term/', '', $link['href']);
+        $nids = array_keys(nat_get_nids($tids,false));
+        if($nids[0]) {
+          // Link back to the NAT node and not the taxonomy term page
+          $links[$module]['href'] = drupal_get_path_alias("node/{$nids[0]}");
+        }
+      }
+    }
+  }
+}
+
+/**
  * Retrieve all vocabularies.
  * 
  * @return $vocabularies
