Submitted by admin on Wed, 09/04/2019 - 14:42

Image removed.

One of our members wanted to create a taxonomy of Countries, Provinces and Districts.

For example, you might choose England, then Yorkshire, then Leeds. Or you might choose Canada, then Ontario, then Toronto. You get the idea.

In this tutorial, we'll use the Hierarchical Select module to make that happen.

Step #1. Get set up

First, you need to set up your taxonomy. I've a simple example here with Countries and Cities, but you'll probably add a lot more terms.

Image removed.

Next, install and enable Hierarchical Select: https://www.drupal.org/project/hierarchical_select

Make sure to enable "Hierarchical Select Taxonomy":

Image removed.

Step #2. Create the field

  • Go to Structure > Content types > Manage fields.
  • Create a new field. Choose "Term Reference" and then "Hierarchical Select":
Image removed.
  • Save the field.
  • Click the "Hierarchical Select" link.
Image removed.

You'll now see a series of options for the field:

  • Save lineage: Save all term levels (City and Country) or just the one the user chooses.
  • Level choice: What level can a user choose from? Only City? Other other levels too?
Image removed.

Under "Level labels" you can give labels to the different levels of the taxonomy:

Image removed.

Under "Dropbox settings", you can decide how many choices a user can make:

Image removed.

And under "Editability settings", you can decide whether the user can add new terms and levels to our set-up:

Image removed.

Step #3. Use the field

Finally, click "Add content" and use your field. Here's how the top level will look:

Image removed.

And, once the first level has been selected, here's how the second level will look:

Image removed.
Solutions Img