I love BEF and the features it provides, especially the checkboxes for exposed views filters. I was wondering though, is there a way to collapse/expand according to the hierarchy?
I have a hierarchical taxonomy vocab with a depth of 3 or 4 and there are only a handful of parents and children but over a hundred grandchildren.
So it would be great if not just the root, but also all the sub-parents could be collapsible/expandable as well (like in the interface of Taxonomy Manager). Is this possible?
My clients need their website done this week so this feature request isn't really for me, but looking at drupal forums I think it would be a HUGE improvement over the views default UI (and it would have been awesome for me! :)
mikeker, thanks for all the work you've done on this. I wish I could do more to help the Drupal community and give back.
Comments
Comment #1
jadenoel CreditAttribution: jadenoel commentedPosting this feature request in reference to comments 5, 6, and 7 on this thread: http://drupal.org/node/965388.
Comment #2
doublejosh CreditAttribution: doublejosh commented+1 and visiting the feature request link.
Was going to do this by pointing some simple jQuery UI scripts at the filter DOM elements, but there is no hierarchical structure to point at :(
Comment #3
mikeker CreditAttribution: mikeker commentedI actually checked in the fix to this ages ago, but for whatever reason, I forgot to mark this issue as fixed. Heh... Sorry about that. This option is now available in the -dev release.
Selecting "Nested checkbox/radio buttons" puts the filter into a nested
<ul>
. There is currently no JavaScript added to collapse/expand the lists but that should be relatively simple now that there's an appropriate structure to work with.Note: this ONLY works with a Taxonomy filter that has the "Show hierarchy in dropdown" option checked and relies on the "-" prefix to determine the current depth. The "-" characters are removed from the filter options.
Comment #4
doublejosh CreditAttribution: doublejosh commentedAwesome. Guess this negates the other thread I wrote about this in :)
Comment #6
jacobroufa CreditAttribution: jacobroufa commentedI know this is a closed issue, but I was still having some problems with what JS to use to make a collapsible list work properly so I thought I'd post my solution for the benefit of others. I went through 4-5 different variations before settling on this.
Must be using the latest -dev branch of BEF. Also requires Jquery 1.5 via jquery_update and the jquery-tree plugin. Once you have patched jquery_update and included the plugin above in your theme, create a new JS file and include it either using drupal_add_js() in your template.php or scripts[] = js/script.js in your info file. Below is the code that worked for me :
Note: If you enable the context if statement found here then ajax auto-submit and the tree only work one time. Without the context statement they are persistent.
Comment #7
alanom CreditAttribution: alanom commentedThe Term Reference Tree Widget module includes a great piece of javascript designed specifically for Drupal taxonomy tree hierarchies. They've also got an open issue on more or less the same topic.
How about an option that appears if Term Reference Tree Widget module is installed to use its javascript?
Comment #8
Peacog CreditAttribution: Peacog commentedI've written some very simple javascript to expand/collapse the nested lists provided by the Nested Checkboxes/Radio buttons widget. Add the following to your theme's behaviours:
It should be reasonably easy to add this as an option in the filter settings. When I have some time I will make a patch.
Comment #9
ShaneOnABike CreditAttribution: ShaneOnABike commentedThat code didn't work for me but this did...
Comment #10
nassiesse CreditAttribution: nassiesse commentedHi All,
This solution is OK, but I think there is a problem.
When BEF applies the filter to the view it refreshes the page and the state of filters were lost.
How can we save the state to prevent its lost?
Comment #11
FaberfoX CreditAttribution: FaberfoX commentedHere's my solution, I've just started with jQuery last night so I'm sure this can be improved.
In my case, I didn't want to have to click the parents to show childs as that doesn't work for my use case, I don't want the parents checked when expanding. So, this code inserts a span with a + in front of the parents to have it be the one in charge of expanding and collapsing children. I'm using an initially undefined var to have this processed just once, because otherwise ajax refreshes were triggering the function again, adding extra expanders. Once more, I've just started with jQuery so please don't shoot me. Also, with the selectors I'm using, the select all/none is not required as it was in #9.
This will only work for 2 level trees, I hope someone that knows more than me can refactor it for any level trees.
I'm using Code per Views dev to insert the JS and so far it's working great.
Comment #12
knigh7 CreditAttribution: knigh7 commentedAny luck with this?
Comment #13
nassiesse CreditAttribution: nassiesse commentedI solved this problem using the jquery.cookie plugin (http://archive.plugins.jquery.com/project/Cookie) that is already included in Drupal 7 distribution.
I modified the script on post #9 to save in a cookie the opened accordion id, so I can set it as open on the next post.
I hope this is usefull.
Comment #14
forpost CreditAttribution: forpost commentedTry Simple hierarchical select
"The widget is available in node forms and as Views exposed filter."
http://drupal.org/project/shs
Comment #15
ah_ma81 CreditAttribution: ah_ma81 commentedI am using this module (Code per Views Display) to add this codes and none of them is working ... can any one please tell me what i have to do
Comment #16
m-si CreditAttribution: m-si commentedHi I have been codeing arround to have a working solution for folding taxonomy hirarchies in a views filter that ist renewing itself via ajax. It is ugly coded, maybe some of you guys do have an Idea to shorten it. It overcomes the double binding of function of #11. It works for all levels nested. I included it in the .info file via
scripts[] = scripts/expcol-bef-tax.js
Comment #17
golddragon007 CreditAttribution: golddragon007 commentedHere is an actual version of #16 with some cleaning and optimalization.
Comment #18
bib_boy CreditAttribution: bib_boy commentedIf you are using an admin theme (e.g. Seven) then remember to add the script there and not your main theme!
Comment #19
hockey2112 CreditAttribution: hockey2112 commentedWas this feature ever implemented into the BEF module? If not, is there a modern/current code implementation that would work for Drupal 10?