Simple musings of a Drupal developer.

Taxonomy Enhancer is not out for Drupal 6

By krs · October 23, 2008 · 1 Comment · 213 Views

Thats too bad, this is a really useful module for adding data to taxonomy terms and vocubularies. There is a patch brewing, but its just not ready yet. I had a client that was using taxonomy to define seasons for products (for example "Fall 08", "Holiday 09", etc). The taxonomy part was working great, but how do you know when a season starts or ends? These aren't necessarily your standard spring/summer/fall/winter, they can be fairly arbitrary. It would be nice to be able to store that information about a term without having to write a whole custom module, but unfortunately no Taxonomy Enhancer.

So how hard is it to replicate the functinality from that module? Not too much trouble, just 2 hooks in fact.

hook_form_alter() checking for a $form_id of 'taxonomy_form_term' will let us add the fields to the page. In our case we only wanted this for terms in one vocabulary, so we also checked the vid and that the user had permission to edit the product seasons.

the second part is using hook_taxonomy() to save the date. This hook gets called anytime a term or vcabulary is inserted, updated, or deleted. So we check to make sure that

  1. its a term being modified (not a vocabulary) ($type == 'term')
  2. its in the the vocabulary we're interested in ($array['vid'] == SEASON_VID)
  3. the user has permission to edit this kind of data (user_access('administer seasons'))

 

If all of the above are true we store the data, and we're free to call it back later and make sure we're only showing the user the product seasons s/he is supposed to see!

Filed in: ,
Tagged with: ,
posted by Anonymous
Wed, 03/11/2009 - 12:52pm

Looks like they are joining forces with the guys from "Term fields",
http://drupal.org/project/term_fields


Post New Comment

If you are already an OnSugar member, or would like to receive email alerts as new comments are made, please login or register for OnSugar. Or connect with your Facebook account: .
The content of this field is kept private and will not be shown publicly.

About Me

Drupal.org username: kscheirer

subscribe

Drupal Cred

Drupal Camp Los Angeles 2009 - August 8-9th

Archive

August 2009
SMTWTFS
 1
2345678
9101112131415
16171819202122
23242526272829
3031 
July 2009
SMTWTFS
 1234
567891011
12131415161718
19202122232425
262728293031