Home ›
Drill Down Taxonomy Terms (Free-Tagging Facets) | drupal.orgDrill Down Taxonomy Terms (Free-Tagging Facets) | drupal.org
Submitted by Kathleen Murtagh on June 21, 2009 - 12:52am
Link Title and URL:
Drill Down Taxonomy Terms (Free-Tagging Facets) | drupal.org After a bit of fiddling, I tried David's solution in #18 to cubbtech's request from #17. While it only required a few lines of code (maybe 20 or so all told), the changes were scattered about several files. Given the hacky nature of the changes to my already-patched Drupal 6 version I won't submit a patch here.
Nonetheless, here's a rundown of how I got it to work for multiple-select taxonomies:
- Noticed that repeating categories already "just works" as far as search is concerned. If you give a search URL that includes two taxomony terms from the same vocabulary, you get the correct search result and the proper remover links in the "Current Search" block. Thus the most potentially hairy part, dealing with the SQL generation code, was already working just fine without any changes.
- In order to allow multiple filters for the same vocabulary, added a "$vocabulary->multiple ||" clause to the if statement just below the comment "// If the vocabulary's corresponding facet is allowed" in taxonomy_facets_faceted_search_collect(). This short-circuits the logic preventing two filters/facets for the same vocabulary. A this point we're half-way home except for some UI changes.
- Added some logic to faceted_search_ui_build_categories() to eliminate any duplicate categories (i.e., those that have already been selected) from being displayed. (Why there? Because it was a place where we could get at all of the facets and categories at once.) I had to assume that two categories from the same vocabulary with the same label were equivalent and thus duplicate. This might cause some problems in hierarchical taxonomies where labels can be duplicated at different points in the tree. API suggestion: how about adding an equals() method to categories to make detecting duplicates easier? The method could be over-ridden for classes that need to do anything more sophisticated than compare labels.
- To avoid some UI confusion, disabled the showing of filters with active categories in the Guided Search block. This of course means that I have to use the Current Search block to broaden the search, but that works o.k. for me. I actually prefer it that way anyway.