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 :-)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fmueller_previon created an issue. See original summary.

florianmuellerCH’s picture

blake.thompson’s picture

I was looking for this as well. Adding my own rendition of a patch, a little slimmed down.

blake.thompson’s picture

FileSize
674 bytes

Resubmitting, accidentally had prefixed space when no hierarchy

blake.thompson’s picture

FileSize
742 bytes

Fixing patch, .repeat() doesn't work in IE11.

borisson_’s picture

Status: Needs review » Fixed

Committed and pushed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.