Hierarchical Select

3 March, 2008

API {#api}

The API of the previous version of HS was a beast. Well, not the API, but the implementations. This has been fixed in version 2 of HS: it’s now much more elegant and much easier. If you don’t have to alter any forms, you can easily implement all hooks in less than a hundred lines, probably even less. The content_taxonomy implementation for example, is about 75 lines if you don’t count the form altering. That should make HS much more attractive to other Drupal developers.

Support Hierarchical Select Dynamically {#support-hierarchical-select-dynamically}

One of the low-hanging fruits is to support HS dynamically (i.e. use hierarchical select form items when HS is installed, use normal selects otherwise).

If your module provides its own hierarchical structure for which you want to use HS, you’ll have to implement the hooks. Next, I assume you have something like this in your form:

3 March, 2008

What is Hierarchical Select? {#what-is-it}

For those who don’t know Hierarchical Select yet, or HS in short, this is a module that provides a new form element. If you’re new to Drupal, you may just have frowned upon reading that. A ‘form element’ in Drupal’s Forms API is something like a button, select or textarea element in HTML, or a GUI widget in a GUI.

Now, the goal of HS is actually very narrow: making selections in hierarchies (hence its name) really simple: improve usability. The prime example and candidate for this is of course Drupal’s Taxonomy module. The idea is to first select an item from the root level, then pick one of its children (if it has any), then one of the children of the selected child (if it has any), and so on.

New and Improved {#new-and-improved}

There are many new features in version 2 of Hierarchical Select (or HS in short):