Closed (outdated)
Project:
Views (for Drupal 7)
Version:
7.x-3.x-dev
Component:
exposed filters
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Jul 2011 at 10:10 UTC
Updated:
14 Mar 2019 at 01:06 UTC
Jump to comment: Most recent
Comments
Comment #1
dawehnerSo what does this code snippet do for you at the moment? Perhaps you have to call a drupal_render with #theme here.
Comment #2
cajmcmahon commentedThe code allows me to expand and collapse a fieldset containing three exposed filters. It works perfectly.
I think I might have a javascript problem however, as I noticed I can no longer collapse the fieldsets on the Modules page (/admin/modules/list), nor can I expand/collapse Collapsiblocks.
In case it's a theme issue, I tried with Bartik, Seven and Zen.
I'm going deactivate any modules that I've installed in the last few days as the Modules page fieldsets did work last week.
I'll report back with any findings...
Comment #3
cajmcmahon commentedGot javascript functionality back. I just de/re-activated JS modules (also moved them out of sites/all/modules folder while doing so). Didn't learn much unfortunately.
Will continue to experiment with the theme-based preprocess function (though I think Collapsible blocks is the way to go for me on this one).
Comment #4
dawehnerThat's basically just a support question how to use the drupal7 api.
Once you would have fixed it, this isn't views specific.
Comment #5
cajmcmahon commentedThat's true about D7 usage. The solution for D6 appeared in Views queue so I followed that lead. Thanks.
Comment #7
Vote_Sizing_Steve commentedHere's some (sloppy) code I put together, which seems to do the job:
... it needs some tidying in order to make it drupal compliant.
Comment #8
davidwhthomas commentedThis is what worked for me in the end, in Drupal 7:
Comment #9
Yuri commentedthe code in #8 gives me this error:
Notice: Undefined index: #children in theme_fieldset() (line 2673 of /home/office/public_html/includes/form.inc).
Comment #10
rp7 commented#7 #8: Unfortunately, to be XHTML compliant, a fieldset must be in a form, instead of around it.
Any other idea's anyone?
Comment #11
Yuri commentedAs a workaround i applied the patch mentioned in http://drupal.org/node/1004852
which resulted in the #9 error message not showing up any more.
Comment #12
meba commentedI think this should actually be re-opened, it is not only an issue of using D7 Forms API. The problem is that some of the exposed filter form parts such as titles are not generated as part of Forms API.
Maybe this? http://drupal.org/project/better_exposed_filters
Comment #13
tbrowninfinitymark commentedIs this a standard feature now in Drupal Commons? I do not wish to have collapsible filters (collapsed by default) but can't seem to locate a way to turn it off in D6 Commons. Can anyone point me to a solution? My searches thus far have turned up nothing.
Thanks!
Comment #14
ahwebd commentedBased on #8 here's how I done it for specific views and only for a part of the exposed filters:
adding: '#children' => '', will remove the error described in #9
Comment #15
davidwhthomas commentedHere's my adjusted version from #8 to avoid the unset #children notice error:
Change EXAMPLE to your theme name, or module name and clear all caches.
Comment #16
mstef commented* EXAMPLE_preprocess_views_view (remove "_content")
Comment #17
davidwhthomas commentedThanks for the tip _content string removed from function name.
Comment #18
levakon commentedThe code from #14 works nice for me, any ideas on how to add the option for filters to be expanded by default if one of them is set (for example if there are 5 filters and user inputs something in one of them, when the form is submitted the filters are not hidden again but stay open so he can simply change what he entered -> or add some other text to other filters).
and how would one go about making more than one fieldset, for grouping similar filters together.
thank you for any info
Comment #19
dawehnerYou could store the status of the fieldset in a cookie and open this automatically via javascript once the page is loaded.jjj
Comment #20
mstef commentedThe code already does that levakon. See:
Comment #21
dawehner@mikesteff
Oh this is a nice trick! Thanks for sharing.
Comment #22
mstef commentedyea, it's a good one - thanks davidwhthomas.
Should we turn this into a feature request? Seems like a cool option for views..
Comment #23
levakon commentedmikestefff, thnx for that, i took the code from #14 and added that so i can group only some part of filters not all of them, that works well when there is only one fieldset, i'm also wondering if there is a simple way to make more than one fieldset (for example to group filters in 3 categories and can be collapsed/expanded independent from each other) and then when the results are shown to have expanded field set if at least one of the filters inside that group/fieldset was set.
(i'm guessing it would work with storing the status in a cookie or by looping the list of $_GET variables and checking which ones are set and then either set $collapsed to FALSE or TRUE.
is there a better/simpler/nicer way? (i'm always surprised how simple some things can be solved and go "oh, why didn't i think of that way...")
Comment #24
Yanxi commentedCould anybody tell me how to implement the code in #14 pleae? I have tried the followings without success.
1. Change MYTHEME to my theme's name and put these codes in my theme's template.php file;
2. As I only need to add this fieldset to one views exposed filter, so I replace ('view1', 'view2', 'view3') with ('my_view_name').
p.s- I am not sure if it is 'my_view_name' or 'my view name' or 'my-view-name' etc but I have tried them all without success.
3. remove the codes for case 'view1' and case 'view3'
4. Change 'view2' to 'my_view_name' and change "edit-myfilter2-wrapper"' to my filter's id.
Am I missing anything?
Comment #25
davidwhthomas commentedYanxi, something like my_view_name for the view name, you'll need to clear cache to register the new preprocess function, e.g visit your theme settings page in admin and save it.
Comment #26
abtm commentedI have the same problem and after clear the cache it still doesn't work.
Comment #27
Yanxi commented@davidwhthomas, thanks for your prompt reply. I did clear the cache and save the theme settings page, it still doesn't work. :( I put the following codes in my theme's template.php file, could you see anything wrong in it?
Comment #28
Yanxi commentedStill can't make it work...Any help would be appreciated.
Comment #29
davidwhthomas commented@Yanxi
I use the code I posted in #15
Can't comment further on the other author's snippet besides to say check your view machine name ( my_view ) is correct.
Good luck,
DT
Comment #30
Yanxi commented@davidwhthomas: Thanks again for your reply. I tried your code before and it didn't work either. Just tried it again. Guess what I discovered......
Your code works on the exposed filter that is not exposed in block. The exposed filter I was trying to have a fieldset in was exposed in block. I also went back to try the code at #14 and it displays a fieldset but the "Advanced search" title is not collapsible. I then put your code
drupal_add_js('misc/form.js'); drupal_add_js('misc/collapse.js');in the #14 and the "Advanced search" title becomes collapsible.So I think both your code and the code in #14 might not work on the filter exposed in block, right? If so do you know how to make it work? Thanks.
Comment #31
aacraig commentedBuilding on #15, I've modified it a bit so that the fieldset is inside the form, so that the resulting HTML should validate:
Comment #32
killah89 commentedHello,
in my theme Bootstrap the fieldset dont open. When i change $collapsed = TRUE; to $collapsed = FALSE; the fieldset dont close. Can anyone please help me out?
Thanks.
Comment #33
killah89 commentedFixed my problem by myself. Now my exposed filters, are in a modal window with bootstrap theme. See this post https://drupal.org/node/2160177 for a simple guide and code.
Comment #34
remoraxxx commentedSolved #32
Just add an id to the fieldset in order to collapse/expand it properly ( and optionally remove
collapse.jsandform.jsin order to use the bootstrap functions instead of Drupal ones)Comment #35
kumkum29 commentedHello,
is it possible to reorder exposed filters in several fieldsets, inside the master fieldset?
How to create some fieldsets, inside master fieldset? How to include exposed filters in those new fieldsets ?
Thanks.
Comment #36
killah89 commentedI dont know, how to create other fieldset in a fieldset for exposed filter. But i know that exposed filters can you create in your view. To order the filters, click on the arrow by exposed filters an then on reorder. Voila you can reorder your exposed filters ;)
Hope you understand me and i hope i understand you correctly :D
Regards,
KiLLAH89
Comment #37
mgrim commentedWhen using exposed filters in a block, the $vars['exposed'] array is empty. Where are the fields contained in this situation?
Comment #38
anybodyThis is still an important thing for further development of views I think. I've had thousands of situation where a collapsible fieldset had helped me a lot :(
Could you please consider to add this to a future views version or make it possible via module simply?
Comment #39
StevenMouret commentedFor Drupal 7
Comment #40
polYou can also use this module: https://www.drupal.org/project/views_ef_fieldset
It allows you to configure the title, description and attributes of the fieldset too.
Comment #41
osopolarSee also the issue #2450043: Submit button inside secondary fieldset of the Better Exposed Filter module if you don't need multiple fieldsets.
Comment #42
bwaindwain commentedSlight improvement on #31 and #34, change
to
(or whatever your filter values are), so that clicking a table column header to sort won't expand the filter
Comment #43
mustanggb commentedClosing this as outdated to tidy up a bit around here. If you're still having problems with the latest release please create a new issue.