A better way to select taxonomy terms

A better way to select taxonomy terms

Posted 12/31/2007 - 18:31 by Michelle

When building a business directory that will have non-admins adding entries and selecting categories, you need to make it as easy as possible. By default, Drupal offers up a multi select box to scroll through possibly hundreds of terms and control-click the categories you want your entry to be in. Definitely not user friendly.

When I was building the directory, I spent some time looking at the various taxonomy modules to find something to simplify choosing categories. There was nothing that really did what I wanted, though, and my javascript skills are non-existant so making my own was out of the question. The best one I found was taxonomy super select, which is a nice module, and does simplify it, but was still bulky and awkward with the number of terms I have.

Then along came Hierarchical Select which was tantalizingly close but lacked one requirement: multi select. I really need people to be able to put their entries in multiple categories. So again I was stuck. Fortunately, that has changed. As of version 2 beta 1, Hierarchical Select now lets you select multiple categories in a simple, easy to use, UI! Interested? You can see it in action by adding an entry to my La Crosse area directory. Please don't actually save the node as this is the live site. My dev site needs to be updated with the latest so I can't use that. You don't actually need to save the node to see it work, though, so check it out.

Thanks to Wim Leers for his work on this much needed module.

Interesting demo

Thanks for the suggestion of this module, which can be useful elsewhere.

Just wanted to warn you that the combination of the site theme + the module JS is broken in Opera 9.25: level 1 is ok, level 2 appears normally, but once you validate a choice, it climbs up to the same position as level 1, and level 3 appears at that position too.

Posted by FGM (not verified) on Tue, 01/01/2008 - 03:24
Opera is the only browser that can't handle the CSS

It seems Opera is the only browser I've tested with that can't handle the CSS. I've tested in Firefox 2, Safari 2, Safari 3 and Internet Explorer 6. Since Opera has such a minor market share, I'm not going to put any work into this (and because I'm no CSS wizard). I've created an issue for this.

Posted by Wim Leers (not verified) on Tue, 01/01/2008 - 12:36
Great

That is a really good directory implementation, love it. What is the top level page? Is it a View, custom code or something else?

Perhaps one possible improvement would be to not display categories with 0 entries, but I could also see cases where that acts as a guidance to add something...

And the "Hierarchical Select" module is fantastic...thanks Wim Leers.

Posted by NicolasH (not verified) on Wed, 01/02/2008 - 05:49
Pointers galore

Oh well...should have looked a bit closer earlier. You've already started a write-up...

http://shellmultimedia.com/tutorials/building-area-directory

That's got enough pointers.

Are you available for freelance work?

Posted by NicolasH (not verified) on Wed, 01/02/2008 - 06:07
She has a contact form!

Thanks for the compliment, Nicholas.

And you can ask her more directly about freelance availability via her contact form.

Posted by Wim Leers (not verified) on Tue, 01/08/2008 - 09:45
Freelancing

Sorry, Nicholas. I missed this until Wim pointed it out. I'm actually pretty swamped right now so I can't take anything on. Thanks for the interest, though.

Michelle

Posted by Michelle on Tue, 01/08/2008 - 10:22
A little help with this please...

So i love the Hierarchical Select module and it answers a lot of my needs but... i cant get the results onto the page i have put the following code:-

case 10:
  array_push($worked, l($item->name, "taxonomy/term/" . $item->tid));
      break;
    }

into my template and then echoed it out like this:-
<?php print implode("<br /> ", $worked);?>

this didn't work despite the fact i followed the same model as for my other Categories... any ideas gang?

Posted by mouse77e on Wed, 01/16/2008 - 19:15
Issue queue

Please use the issue queue for support requests on hierarchical select. I have no idea if Wim is continuing to read this blog post.

Michelle

Posted by Michelle on Wed, 01/16/2008 - 21:49
HELP!

I think i mentioned in another post i am dyslexic... having asked Wim my question on displaying the selected multiple choices from the category (see http://drupal.org/node/211047 ) i am non the wiser. can someone help me out here?

Posted by mouse77e on Sat, 01/19/2008 - 18:36
I think i mentioned in

I think i mentioned in another post i am dyslexic... having asked Wim my question on displaying the selected multiple choices from the category i realized i had boobed.

i had ommited to add the line $location = array();

// Split the taxonomy up into one variable per vocabulary
$communities = array();
$hobbies = array();
$reading = array();
$music = array();
$video = array();
$location = array();
foreach ((array)$node->taxonomy as $item) {
  switch ($item->vid) {
    case 1:
      array_push($communities, l($item->name, "taxonomy/term/" . $item->tid));
      break;
    case 2:
      array_push($hobbies, l($item->name, "taxonomy/term/" . $item->tid));
      break;
    case 3:
      array_push($reading, l($item->name, "taxonomy/term/" . $item->tid));
      break;
    case 4:
      array_push($music, l($item->name, "taxonomy/term/" . $item->tid));
      break;
    case 5:
      array_push($video, l($item->name, "taxonomy/term/" . $item->tid));
      break;
    case 10:
  array_push($location, l($item->name, "taxonomy/term/" . $item->tid));
      break;
    }
}

Wim, Michelle, my apologies!

Posted by mouse77e on Sun, 01/20/2008 - 13:20
Having said that i thought I'd better show ya it worked!

Just to show you all what i did here... On my little corner of the web. here is a quick break down for users and if you have a look at the link to My Profile you'll see the prossess in action

PLEASE don't open an account to try it out tho, the site is live!

many thanks

TIm (mouse77e)

Posted by mouse77e on Mon, 01/21/2008 - 11:49
Drupal Noob

Okay, all that went over my head. Would you recommend any books for Drupal noobs? Our site is using Drupal 5 and it was such a huge improvement over the old site. There are some things I like to with the feeds (like add them to a static page, via a "latest news" block) but I'm definitely not a programmer. Found you through the Drupal forum.

Posted by Vegas guy (not verified) on Mon, 03/10/2008 - 16:13
Books

All the Drupal books are listed here. The only one I have is PDD, but that's for programmers.

Michelle

Posted by Michelle on Tue, 03/11/2008 - 09:03
saved my users

For a very long time many users visiting pressreleasepoint.com are complaining about confusion in selecting countries, states and cities while submitting press release to our website. Since this is a free press release website, we did not have enough budget to improve the category select module. I also do not not know JQuery to code a better UI. Now I found out this fantastic hierarchy select module. Thanks a ton to Wim Leers.

Posted by free press release (not verified) on Sun, 06/01/2008 - 01:41