How to split taxonomy vocabularies

Cyclist72 - April 6, 2008 - 11:13

This might be a stupid question to those using Drupal a while. But as I am quite new to Drupal I have some problems with the taxonomy vocabularies. I already created different vocabularies and would like to display each vocabulary with its terms at different regions on my site. By default this is not possible. All vocabularies are displayed at the same region. Is there a way to split the display somehow?

Managing and maintaining taxonomy

asb - April 6, 2008 - 14:45

Hi Cyclist72,

Drupal does not offer by itself any of the functionality you are describing. However, there are several contributed modules that might help:

* Taxonomy Switch, http://drupal.org/project/taxonomy_switch - allows to move terms or subterms between vocabularies; there are some limitations what kind of vocabularies can be handled this way
* Taxonomy import/export via XML, http://drupal.org/project/taxonomy_xml - allows to output a taxonomy into a XML file, that can be edited manually, and reimported
* Term Merge, http://drupal.org/project/term_merge - allows to merge terms together inside a vocabulary

With those tools, you gain huge flexibility in managing vocabularies and it's terms.

If you don't want to split the vocabularies (as the subject suggests), but only distinguish what is displayed in what place inside a node, this module might be worth looking into:

* Term Display, http://drupal.org/project/term_display - Term Display is a small helper module that provides display options for taxonomy terms on node pages

If you need more fine-tuning regarding the display, you might want to look into Drupal's templating system, also.

Regards, -asb

PS: Other useful modules you might want to have a look into if you're dealing a lot with Drupal's taxonomy:

* Node breadcrumb, http://drupal.org/project/node_breadcrumb
* Taxonomy Manager, http://drupal.org/project/taxonomy_manager

More Taxonomy-related modules for D5: http://drupal.org/project/Modules/category/71

Here's what I did.

hyrcan - May 5, 2008 - 05:04

I was just looking around the site to see if anyone else did this so I could compare what I did to what others tried. Only found this post so far...

First I implemented a custom function in the template.php of my theme:
(don't forget to rename the function to include your theme name)

function THEME-NAME_taxonomysplit($vid,$nid) {

  $tmpnode = node_load($nid);
 
  $items = array();

  $terms = taxonomy_get_tree($vid);
  foreach ( $terms as $term ) { 
    foreach ($tmpnode->taxonomy as $taxterm) {
      if ($term->tid == $taxterm->tid){
        print ' ';
        print l($term->name, "taxonomy/term/$term->tid");
        print ' ';
      }
    }
  }
}

Where $vid is the taxonomy vocabulary and the $nid is the node ID of what I want to split apart.

Then In the tpl files I can drop a call to:

THEME-NAME_taxonomysplit($vid,$nid)

Obviously this has it's limitations, mainly you have to know what vocabularies would be attached to the node and reference that in your .tpl file ($vid) Tricky if you have people adding vocabularies all the time. My site only has a few that I care about splitting apart like this so it works for now.

Ideally perhaps a call to get all the vocabularies, then have it run the split putting it all in an array of some sort.

I'm quite interested in feedback on this code, so if anyone out there knows of any cleaner ways of doing this I'm all ears.

Hope it helps point you to the right solution for your site.

Hi, Is there a similar module

macrodesign - June 23, 2009 - 14:11

Hi,

Is there a similar module like taxonomy switch for D6, please advice. Thanks

D

works for me

jriddiough - August 10, 2009 - 16:13

Awesome.. This is how I imagined it would be done, but didn't have the patience to write the code.. works great for me, thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.