Hi,
this is a very interesting module. But the readme.txt is very short. Could you explain briefly what you mean when you say the module wants to preserve hierarchical relationships?
Thanks

Comments

kdebaas’s picture

Title: Explain preservation of hierarchical relationships » Preservation of hierarchical relationships in Image gallery
Component: Documentation » Code
Category: support » bug

Hi,
in trying out the module, I soon understood what was meant by preserving hierarchical relationships: A content type that creates taxonomy terms through NAT, will create child terms of the taxonomy term it is associated with itself. Very nice.

An obvious application of this module would be to create automatic Image Galleries for specific content types. Unfortunately, the hierarchy does not seem to be preserved in the Image Gallery vocabulary.

Let me explain better what I have tried: I created a content type called "Project". Through NAT, it creates terms for the vocabularies: Image Galleries, and Projects. For every project, an image gallery is created. If I create a project that is a child of another project, i.e. it is associated with a term from the Projects vocabulary, then it creates a new term that is a child of the first term in the Projects vocabulary. It also creates an image gallery, which is however not nested inside the first gallery.

ray007’s picture

Maybe being able to specify a parent-term in hierarchical vocabularies would be a good first step?
At least it would allow me to create image galleries in different part of the hierarchy for different nodetypes. Or is that already possible and I have missed how to do it?

vacilando’s picture

Zen, I really must congratulate you for this module, it has filled a great gap in the taxonomy system. Especially I love how hierarchies are created automatically. Keep up the great work!

jpsalter’s picture

Here is the hack I used to keep my image gallery's hierarchy. Replace the whole function or just add the "elseif" part.


function _nat_update_terms($terms, $title, $body, $hierarchy, $relations = array(), $synonyms = null) {
  $edit = array(
    'name' => $title,
    'description' => $body,
    'weight' => 0
  );

  if (!empty($synonyms)) {
    $edit['synonyms'] = $synonyms;
  }

  foreach ($terms as $term) {
    if (isset($hierarchy[$term->vid])) {
      $edit['parent'] = $hierarchy[$term->vid];
    } // keeps image galleries (and terms in other vocabularies) from losing their parent
    elseif(count(taxonomy_get_parents($term->tid))) {
      $parents = taxonomy_get_parents($term->tid);
      $parent = current($parents);
      $edit['parent'] = array($parent->tid => $parent->tid);
    }
    else {
      $edit['parent'] = array();
    }

    if (count($relations)) {
      $edit['relations'] = $relations[$term->vid];
    }

    $edit['tid'] = $term->tid;
    taxonomy_save_term($edit);
  }
}
RobRoy’s picture

Status: Active » Closed (duplicate)

Check out my patch at http://drupal.org/node/188377, I think this is a dupe (sorry I didn't see this before I posted my patch).