Mac Duck
Mac Duck

Reputation: 96

How do I move terms from one vocabulary to another in Drupal 7 without losing the node reference?

I've inherited a site with a very big hierarchical taxonomy:

Vocabulary name: categories
--term: company name
---- many child terms
-- term: country
---- many child terms
-- term: issue
---- many child terms

I realized it would be easier to create Search facets and Views with appropriate content if I set up each of these parent terms as their own Vocabularies:

company
country
issue

So I created the new Vocabularies and used Taxonomy Manager to shift all the sub-terms to their new vocabularies. I then updated the Article node content type to be associated with these 3 vocabularies.

Unfortunately I also noticed the term relationship between the Article nodes (all 4,000 of them) and the Terms was now lost in the display. I thought this relationship would have been maintained by the Taxonomy Manager module.

I've been searching for a way to update the vocabulary references for the Article nodes, but I'm still not sure how the vocabulary is associated with the node. I see new field_data_field_vocabulary-machine-name tables are created for each new vocabulary - and this is where the termID and node/entity ID are associated. However I don't know how to update the Vocabulary for a node automatically when I move a term from one vocabulary to another.

I've recently move this site from Drupal 6 to 7 so it doesn't help that there are a lot of dead tables from D6 cluttering up the database.

--

I've now set up a new standard D7 install and am looking at the db default tables trying to figure out where the Vocabulary/Node relationship gets defined. On my old db the TermIDs still seem to be correctly associated with the Nodes in the Node table... but I don't see where the VocabularyID/TermID/NodeIDs are stored/updated.

Upvotes: 2

Views: 2702

Answers (3)

Irgnet
Irgnet

Reputation: 1

I think you should :

  1. Create new vocabularies
  2. Add fields with term reference to new vocabularies
  3. After you connect content type with new vocabularies, then you should move terms to new locations

I tested and it works for me with this order.

Upvotes: 0

Anand
Anand

Reputation: 111

Please try this module: http://drupal.org/project/taxonomy_manager

This module provides a powerful interface for managing taxonomies. A vocabulary gets displayed in a dynamic tree view, where parent terms can be expanded to list their nested child terms or can be collapsed.

The Taxonomy Manager has following operations and key features:

dynamic treeview mass deleting mass adding of new terms moving of terms in hierarchies merging of terms (using the Term merge module in 7.x) fast weight changing with up and down arrows (and AJAX saving) AJAX powered term editing form simple search interface CSV Export of terms i18n support for multilingual vocabularies (per language terms) Double Tree interface for moving terms in hierarchies, adding new translations and switching terms between different vocabularies For using the Taxonomy Manager you should have JavaScript and automatically load of images enabled in your browser.

Upvotes: 1

Boriana Ditcheva
Boriana Ditcheva

Reputation: 2015

-> but I'm still not sure how the vocabulary is associated with the node

In Drupal 7 taxonomy references are done very differently than they were in Drupal 6. If you want to associate a vocabulary with a node in Drupal 7, you have to add that term as a field on the content type:

  1. Go to admin/structure/types/manage/article/fields where you can add/delete/modify fields for your article content type
  2. Add a new field, name it whatever you'd like, and make sure you choose type 'Term reference' from the drop-down
  3. Make sure you choose the correct vocabulary for it to pull from
  4. Repeat this step (add two more fields) for the remaining two vocabularies.
  5. Go to admin/structure/types/manage/article/display and modify whether you want these new fields to be displayed on the node or to be hidden

=============== Addition ==================

In Drupal 7, since terms are just like any other field, you'll see the relationship in the DB (of course -- only once you add the appropriate term reference field to your content type) in a newly created table that stores the information about that field. For example, it may be called field_data_field_tags for the standard 'tags' vocabulary that comes with Drupal 7 by default. In that table you'll see the columns entity_id (that's the node's id) and field_tags_id (that's the term's id), but that column may have a different name for your specific term. So you would have three separate tables for each of your terms' relationships to your node, since they would be three separate fields in Drupal 7.

Does that help a little more?

Upvotes: 0

Related Questions