I have multiple Taxonomy Terms which have the same "Term Name" (with different TID). And I need to make term relations between all the terms with the same term name.

For example:

    term-A (tid=1)
    term-A (tid=2)
    term-A (tid=3)
    term-B (tid=4)
    term-B (tid=5)
    term-B (tid=6)

Then I would like to make term relations between term A and also between term B

Is there any way I can do this automatically? As I have thousands of this kind of terms it's not realistic to do it manually.

  • are you using views?
    – au_stan
    Apr 11 '12 at 19:27
  • Yes I'm using Views and I need term relations to display all the nodes tagged with related terms together in a same page
    – chinita7
    Apr 11 '12 at 19:43

I don't think you really want to just display the related terms. Thats a complicated band-aid to a problem you probably would be better off actually solving.

This type of problematic data is often encountered as part of a migration so it is definitely do-able in a migration like process.


  1. Decide which tid is going to be authoritative.
  2. Find all duplicates of that term.
  3. Re-assign all references to that duplicate term to the authoritative term.

Install the Taxonomy dupecheck module so you don't get in this kind of trouble again. Some details from its project page:

Taxonomy dupecheck module prevents Drupal administrators from adding duplicate taxonomy vocabularies and/or terms. It's helpful when entering large amounts of terms or vocabularies in situations where each value must be unique. This saves time by preventing administrators from having to enforce a unique value policy through later cleanup of duplicate terms.

The module provides a configuration screen allowing administrators to choose which should be unique: taxonomy terms, vocabularies or both. It defaults to case-insensitive comparisons, with an option to change to case-sensitive. Both stored and input terms/vocabularies are trimmed before comparison to handle cases such as 'foo ' and 'foo'. Based on the settings, the user will see an error message when adding a duplicate value.

Caveat: due to the inability of hook_taxonomy_term_presave() to stop the saving process, this only works in the taxonomy term and vocabulary forms. If you want to prevent duplicates through other entry points, this module will not prevent that. If someone knows a way around that I will happily add that in, as that was the original plan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.