I've created a vocabulary, I can add terms but I want to "configure" this taxonomy to add terms with only 2 levels.

I'm talking about the default table that show my vocabulary terms (drag and drop system). How can I make it set only a term and sub-terms (disable sub-sub-...-subterms)?

I've tested the select module but as long as I can add multiple hierarchic terms, the select module add them as well, so it's not the solution

Thank you all

1 Answer 1


The theme function theme_taxonomy_overview_terms() drives the taxonomy overview table you're describing. The Drupal API function drupal_add_tabledrag() has an 8th parameter $limit that specifies the maximum depth of hierarchy. If it's set to 1, it will do what you describe.

In your theme, you can override theme_taxonomy_overview_terms() so the $limit is to 1. In order to do this.

  1. Copy theme_taxonomy_overview_terms() to your theme's template.php.
  2. Rename the function to MYTHEME_taxonomy_overview_terms in your template.php.
  3. Alter the line drupal_add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE); so that the 8th parameter is 1 (i.e. change it to drupal_add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE, 1); )
  4. Flush your theme cache to pickup the updated taxonomy overview page.
  • Hi Shawn and thank's for your answer, I just want to know, what if I add the limit on the "theme_taxonomy_overview_terms()" without copying it on template.php ?
    – Mitch
    Commented Jul 8, 2015 at 8:32
  • I mean your answer is THE answer, and it works for me, but I'm just wondering if I didn't copy and past on template.php what would be the problem ?
    – Mitch
    Commented Jul 8, 2015 at 8:40
  • You mean if you altered theme_taxonomy_overview_terms() directly? That runs into the problem of hacking Drupal core. In this case, it wouldn't be a huge deal, but it's something you should avoid.
    – Shawn Conn
    Commented Jul 8, 2015 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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