I have been tearing my hair out a bit trying to figure out how to save a whole taxonomy lineage in Drupal, so that everything tagged with a child term would be tagged with a parent term. In other words, given a taxonomy like:

  • 1. United States
    • 3. California
    • 4. Vermont
  • 2. Canada
    • 5. Alberta

I want it so that if I tag something as California (term 3), it also gets tagged as United States (term 1). The Hierarchical Select module does this, and much more, but it has conflicts with other Drupal modules I want to use, so I just gave up on it.

Finally, I realized that I could simply turn it around and solve this on the data retrieval end, rather than the data storage end. In Drupal, if you enter a standard Drupal path like /taxonomy/term/1, that shows only nodes tagged as United States, but /taxonomy/term/1/all shows all nodes tagged United States and all nodes tagged with child terms.

I’m trying to build a drill-down directory of professional ski instructors (emphasis on trying — it’s still pretty rudimentary now and doesn’t yet have any instructors really). I realized that I could use the Advanced Taxonomy Blocks module to navigate for the drill down and was looking to create an add-on module or a patch for the module so that I could have it add the “all” to the end of the URL. Then I saw this in the settings:
Advanced Taxonomy Block Path Settings
All you have to do is add the /all to the end of the path. It’s built right in to the module settings (go to /admin/settings/taxonomyblocks and click Configure).

So much thanks to Aaron Hawkins, an awesome drupal developer, for this simple way around my problem.

Tagged with:

Filed under: Web Development

Like this post? Subscribe to my RSS feed and get loads more!