Index: nat.module =================================================================== --- nat.module (revision 2716) +++ nat.module (working copy) @@ -68,6 +68,21 @@ return array('administer NAT configuration'); } +/* + This right now just checks for the parent field populated by node_hierarchy. + Could eventually split out and have other modules effect this +*/ +function nat_get_parent(&$node) { + if (!$node->parent) { + return; + } + $parent_terms = nat_get_terms($node->parent); + foreach($parent_terms as $term) { + $parents[$term->vid][] = $term->tid; + } + return $parents; +} + /** * Implementation of hook_nodeapi(). */ @@ -86,8 +101,12 @@ $body = isset($nat_config['body'][$node->type]) ? $node->body : ''; // Add term(s). - $terms = _nat_add_terms($nat_config['types'][$node->type], $node->title, $body, $node->taxonomy, $node->nat['related'], $node->nat['synonyms']); + if (!$parents = nat_get_parent($node)) { + $parents = $node->taxonomy; + } + $terms = _nat_add_terms($nat_config['types'][$node->type], $node->title, $body, $parents, $node->nat['related'], $node->nat['synonyms']); + // Save node-term association in the NAT table. _nat_save_association($node->nid, $terms); break; @@ -100,7 +119,12 @@ $body = isset($nat_config['body'][$node->type]) ? $node->body : ''; // Update term(s). $terms = nat_get_terms($node->nid); - _nat_update_terms($terms, $node->title, $body, $node->taxonomy, $node->nat['related'], $node->nat['synonyms']); + // Get parents + if (!$parents = nat_get_parent($node)) { + $parents = $node->taxonomy; + } + + _nat_update_terms($terms, $node->title, $body, $parents, $node->nat['related'], $node->nat['synonyms']); } break; case 'delete':