I wanted to use facets using a dropdown to be able to use chosen for it, as chosen is a very beautiful and user-friendly library. Having a taxonomy which uses hierarchical terms, I needed to also show that in the facet filter.
Now having everything set up, I realized that the dropdown implementation is not yet capable of displaying the taxonomy term hierarchy in the dropdown, despite the hidden output of the facet having the correct hierarchy (nested ul's). Using the checkboxes, everything worked fine, but I wanted the dropdown.
As the optgroup is not yet ready to be nested, I decided to add spacers in front of the facet value description, which I think is also done by the core selects when displaying hierarchy. As the dropdown widget is written to iterate over every link, despite it's nested position, I simply decided to count parents to get my nested level, and then place the spacer according to it.
In case this is the wrong approach or badly coded, please hint me about it and feel free to improve :-)
Comment | File | Size | Author |
---|---|---|---|
#5 | 3058431-5-facets-add-hierarchy-in-dropdown-widget.patch | 742 bytes | blake.thompson |
#2 | 3058431-1-facets-add-hierarchy-in-dropdown-widget.patch | 768 bytes | florianmuellerCH |
Comments
Comment #2
florianmuellerCHComment #3
blake.thompson CreditAttribution: blake.thompson at Slalom commentedI was looking for this as well. Adding my own rendition of a patch, a little slimmed down.
Comment #4
blake.thompson CreditAttribution: blake.thompson at Slalom commentedResubmitting, accidentally had prefixed space when no hierarchy
Comment #5
blake.thompson CreditAttribution: blake.thompson at Slalom commentedFixing patch,
.repeat()
doesn't work in IE11.Comment #7
borisson_Committed and pushed.