Following up on comment #157 in issue "Reflect hierarchical taxonomy vocabulary in facet" by Robert Douglass.
When using a hierarchical taxonomy as a facet, users expect being able to "unfold" the taxonomy without having to select the parent term. Somehow related to this (and making it worse) when using an or'ed facet, the UI does not behave as generally expected: the parent term forces everything to be "found" and de-selecting the parent also de-selects the child.
There should be a way to unfold a taxonomy facet without selecting the parent term (or at least a way to remove the parent tid while keeping the child's tid in the current filters).
Should the taxonomies be unfolded by default?
Apologies for not having a patch attached to this issue, hopefully this post is the first step in this direction...
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | fix_children_facets.txt | 757 bytes | harrrrrrr |
| #19 | 791916-7.patch | 4.61 KB | jpmckinney |
| #19 | 791916-6.2.patch | 4.57 KB | jpmckinney |
| #19 | 791916-6.1.patch | 4.56 KB | jpmckinney |
| #17 | 791916-17.patch | 4.1 KB | jpmckinney |
Comments
Comment #1
shaneonabike commentedSubscribe ... definitely need this for a project that we are working on.
Here's some standard usability situations that I was thinking about.
* Term Parent
** Sub-term
** Sub-term
Scenario 1: If users check top parent term
* Term Parent (Checked)
** Sub-term (Checked)
** Sub-term (Checked)
Scenario 2: If user unchecks one sub-term (from above) then parent becomes unchecked
* Term Parent
** Sub-term (checked)
** Sub-term
Scenario 3: If users check any sub-term (after looking at child terms)
* Term Parent
** Sub-term
** Sub-term (checked)
Comment #2
samuelsov commentedAfter a first analysis, the good news is that the search work well if we give it the good parameters (only the children tids but not the parent tids gives the good search result).
So we need to change the following :
* add a parameter in the solr facet block - something like a checkbox "Hierarchical behavior" (only for hierarchical taxonomy ?)
* change the classes / javascript in the facet block so it only checked the good box (not the parent if we select only some of the child)
* change the href links in the facet block so it gives the good parameters to the search (exclude the parent from the search if we select only some of the child)
* change the display of the Current search block so it display in a way we can understand exactly what we are searching
Comment #3
rjbrown99 commentedI'm actually looking for the same thing, specifically to roll a Javascript fly-out menu to show the hierarchical choices. It would look similar to the screenshot on the nice menus module, where the children are visible on mouseover.
http://drupal.org/project/nice_menus
Comment #4
samuelsov commentedI don't think we are going to do that afterall. If someone is interested to work on this, please go.
Comment #5
rjbrown99 commentedJust to reiterate what I'm trying to do, I'm working with taxonomy facet blocks and my taxonomies have hierarchy. I'd like the block to show the entire hierarchy upon rendering, then use CSS to hide the children. The ultimate goal is to allow a javascript effect to do a fly-out menu to see and facet on any of the children. This is similar in concept to the existing "see more" functionality inside of theme_apachesolr_facet_list().
One of the first issues is just getting the child terms to show up. They aren't rendered in the block unless you are faceted on a parent term. This seems to relate specifically to apachesolr_search.module, inside the function apachesolr_search_taxonomy_facet_block(). The child terms are returned in the SELECT statement but are subsequently removed with this inside of the while/do:
If you simply remove the unset, the terms will show up on output but they won't be properly indented by hierarchy. I'll keep digging, but in the meanwhile I'm certainly open to thoughts and suggestions.
Comment #6
rjbrown99 commentedNope, I'm wrong. Ignore #5. It's actually pretty easy to output all terms, including children, that have not been clicked.
apachesolr_search.module, function apachesolr_search_nested_facet_items(), you will see an if statement towards the bottom that looks like this:
I simply modified that as follows:
Now it always prints out the entire hierarchy. This seems to be step 1, now it's a matter of tying that up into a block configuration element controlled by a variable.
Comment #7
geerlingguy commentedChanging title to better reflect the issue. If we can get the entire taxonomy to print in the block, you should be able to manipulate it with JS/jQuery pretty easily.
For one of my sites, I want to simply show the entire taxonomy, parents and children together, as I want to be able to facet by individual forums in a heirarchical forum vocabulary.
The slam-dunk fix would be to have a checkbox in the block configuration for taxonomy facets that says "always show child terms" (see screenshot for a better idea of what I'm suggesting). Then I could have my block the way I want it, and @rjbrown99 could have the markup to manipulate with CSS/JS.
Comment #8
rjbrown99 commentedI'm done with my stuff now :)
I did a MYMODULE_nested_facet_items to print out all terms per #6 above. That was a good start. I then did a theme_apachesolr_facet_list to add some CSS classes, theme_apachesolr_facet_link to add more CSS classes, and theme_apachesolr_unclick_link to to the same thing. It took a bit of time to slog through it all but it wasn't terribly difficult. It was actually harder trying to retrofit the nice menus CSS classes to the menu than it was to modify the php code.
You can see it here if you like - look at the first block on the left side for Category.
Comment #9
geerlingguy commentedVery nice! I will have to look into doing it this way... and hopefully being able to modify the core module to provide this as a configurable option.
Comment #10
agileware commentedSubscribing.
Comment #11
shaneonabike commentedThis is great progress although it still doesn't solve the initial issue. Mainly, that when you select a child node it actually chooses all the terms down to the child node.
What happens when you have...
Fruit
* Apples
** Red Delicious
* Bananas
** Manzano Banana
** Plantain
If I select Red Delicious then I am selecting all the terms in the tree which isn't the behaviour that we were trying to discover here. Mainly how to we go about doing an OR of terms so that a person could select 'Red Delicious' and 'Plaintain'. This would then would search for those term ID's specifically.
Or if they selected the parent Fruit it would select the entire Tree of terms.
Comment #12
geerlingguy commentedLooks like we might be able to change the limits displayed in apachesolr_search.module around line 724?
Additionally, we could modify the theme function for the facet list, perhaps... (this is in apachesolr.module, around line 1812... which is a great overture)
I don't have a lot of time right now to work on this, but I'm posting these two snippets for reference, since I'll probably not get back to working on this issue for a bit of time!
Comment #13
mustanggb commentedBased on #6 and #7
Comment #14
mustanggb commentedComment #15
geerlingguy commentedWill review...
Comment #16
geerlingguy commentedThis patch works great! RTBC, for sure! (ignore the attachment... was confused by a 6.x-2.x feature)
Comment #17
jpmckinney commentedAdded uninstall hook. Renamed variable to apachesolr_facet_show_children. Changed help text in block config. Need to be ported to other versions after commit here.
Comment #18
mustanggb commentedReviewed and gets the thumbs up from me (not tested though)
Comment #19
jpmckinney commentedMoved variable_get out of for-loop. Added isset. Committed to 6.1, 6.2 and 7.
#791916 by Network | jpmckinney: Allow facet search block to have children always show
Comment #20
geerlingguy commentedThanks!
Comment #22
harrrrrrr commentedthis doesn't work, it checks for $field_name, but this variable isn't set..
patch fixes it (drupal 6)
Comment #23
pwolanin commented