The idea to display children items for taxonomy terms as views exposed filters do(example on screenshot). For example when the option "Expand hierarchy" in facet display settings is selected. I've attached modified module, but I didn't check the option "Expand hierarchy", only check if current $item has children. My code display only fisrt level of children. I think there must be some recursion to show all. Also I've added some pieces of code from https://drupal.org/node/2283201 to pre-select active facet.

Comments

khiminrm’s picture

I forgot to mention I used patches from https://drupal.org/node/1393928 and from https://drupal.org/node/1935782. And turned on such options in facet display settings "Expand hierarchy", "Limit to one active item" and used operator "OR" for facet. Also code was tested on multivalue taxonomy reference field with parent and children terms values.

khiminrm’s picture

StatusFileSize
new2.65 KB

I've found another one bug in my code - when selected child element, it's parent has link that deactivates the facet and parent itself. So I found the solution in my situation - to use one onether patch https://drupal.org/node/2244933#comment-8697755. I've made some more changes to the facetapi_select.module and made the patch for the latest dev.

marcoka’s picture

marcoka’s picture

this patch also does not yours OPTGROUP. it should do that in my opinion.

marcoka’s picture

Status: Active » Needs work
jody lynn’s picture

The patch doesn't conform to coding standards.

Also your comment in #1 about which other patches you had already applied was confusing, especially since the second link was wrong. Does this patch rely on those other patches or not?

khiminrm’s picture

@Jody Lynn, I've lost one number in the second link. It must be https://www.drupal.org/node/1935782. Yes my approach is based on that patches.

@marcoka, thanks. I've saw that module and jquery plugins which it supports, but for my case Facetapi Select was more comfortable to use.

grndlvl’s picture

Status: Needs work » Postponed
StatusFileSize
new1.16 KB

Ok, since I have been working on things that are very close to this I went ahead and rolled a patch against the current proposed solutions for #2336857: Unable to de-select a value && #1482938: Date facets don't work normally. With that this patch requires that both of the previous ones are applied.

I am just adding the patch here for now and we can discuss if the others are accepted.

grndlvl’s picture

Status: Postponed » Needs review
grndlvl’s picture

Status: Needs review » Needs work

Getting close just need to add extra checking to ensure that all children are active or not. When all the children are active then we don't need to add the opheader for the select since no children will show.

grndlvl’s picture

Status: Needs work » Needs review
StatusFileSize
new1.16 KB

I think we have it now.

Note that by default if "Expand hierarchy" is not selected then children will display as their parent becomes active. Otherwise, if it is selected then all children display for each parent.

grndlvl’s picture

StatusFileSize
new2.24 KB

Whoops wrong patch

grndlvl’s picture

StatusFileSize
new3.67 KB

OK, so there was a still slight oversight where if there aren't any siblings then the hierarchy was still showing in the select for active items. This should be good now.

  • grndlvl committed e9a9650 on 7.x-1.x
    Issue #2284099 by grndlvl, khiminrm: Display children items for taxonomy...
grndlvl’s picture

Status: Needs review » Closed (fixed)