Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
I made a handbook page Handbook entry last year detailing how to add the jQuery slider widget to your filters. I think it's high time it was committed to the module!
Comment | File | Size | Author |
---|---|---|---|
#34 | better_exposed_filters-jquery_slider-1627524-34.patch | 26.09 KB | rooby |
#34 | better_exposed_filters-jq_slider.zip | 36.32 KB | rooby |
#32 | better_exposed_filters-jquery_slider-1627524-32.patch | 25.89 KB | rooby |
#27 | better_exposed_filters-jquery_slider-1627524-27.patch | 19.24 KB | rooby |
#25 | 1627524-25-do-not-test.patch | 11.31 KB | mikeker |
Comments
Comment #1
nagiek CreditAttribution: nagiek commentedComment #2
spanac CreditAttribution: spanac commentedHello,
thank you for this great idea for a patch. I have implemented your patch on: BEF 7.x-3.0-beta1, but when i go to BEF Settings and chose "jQuery Slider" for specific field and click Apply, that does not get saved (after immediately opening BEF Settings that filed is back on Default Double Select list). Any idea?
Can you please post .zip version of the module with your patch that worked?
Thank you
Comment #3
nagiek CreditAttribution: nagiek commentedHi, it works fine for me. There's an almost 1-year difference between the -dev and the -beta, so I would suggest reapplying the patch on the -dev release.
Comment #4
nagiek CreditAttribution: nagiek commentedAnd here's the .zip until the patch is committed, though you should read the documentation for how to apply patches. ;)
Comment #5
spanac CreditAttribution: spanac commentedThank you for the .zip :)
I have tried to apply it on the -dev and beta relese, but it didn't work... So I have asked for the zip version that worked for you :)
Comment #6
srgk CreditAttribution: srgk commentedhey! i have downloaded the zip with included patch (thank you!), and i have successfully set the BEF to jQuery slider on the needed exposed filter.
But nothing happens.
Maybe i'm missing something? i have downloaded and included in the theme's .info jQuery UI 1.8.22 with css
i have flushed the cash several times
do i need to make some extra steps? i'm using latest dev views and ctools
PS maybe i didn't quite understand your "First, js and css should be added via the drupal_add_library('system','ui.slider') function in the template preprocess area." instructions, but i tried it in several ways with no luck
thanks
Comment #7
gynekolog CreditAttribution: gynekolog commentedsame problem like srgk
Comment #8
shrutijain CreditAttribution: shrutijain commentedIm new to drupal. Im using 7.14
Some1 plz tell me hw to apply dat patch?
And is it a jquery range slider patch? If nt plz help me hw to do that
Thanks..
Comment #9
FridgeWheeL CreditAttribution: FridgeWheeL commentedHi,
I have followed the steps as follow but to no avail. My sliders just wont show.
Tested on Firefox 14.0.1, Chrome 21.0.1180.79 and Internet Explorer Version 10.0.8400.0
-I downloaded and activated the Jquery Update 7.x-2.1+9-dev
-I downloaded jQuery UI (tried both 1.7.3 & 1.8.23)
-Placed the jquery-ui-1.7.3.custom.css & jquery-ui-1.7.3.custom.min.js as well as the images folder inside sites/all/themes/"my theme name"/includes
-created a new empty custom.js file as follow sites/all/themes/"my theme name"/custom.js
-Pasted the code for Drupal 7 custom.js by Nagiek and modified it as follow to match my filter identifier:
-Modified my theme_name.info and added the following right at the top:
-I made sure my new views exposed filter is numeric field type with "in between" type selected.
-I am using the patched version ZIP file as mentioned above
-I am a bit lost on @Nagiek’s words here: First, js and css should be added via the drupal_add_library('system','ui.slider') function in the template preprocess area.”
When I try to ad the following
drupal_add_library('system','ui.slider')
code to my template.php I get an error:Parse error: syntax error, unexpected T_FUNCTION.
EDIT: I have managed to get the sliders available as i made a mistake in labelling my filter label instead of filter identifier under the "more" options on the filter settings page.
However, I have decided to not use the slider as it is quite buggy when it gets to big price values such as 0 - 999999999
It will jump to max 100/2000 when the slider is modified as well as the double sliders keep on popping up which also functions differently from one another.
Regards
FridgeWheeL
Comment #10
ceaucari CreditAttribution: ceaucari commentedI was using better_exposed_filters 7.x-3.0-beta2 release date September 13, 2012 at 6:52pm
if I switch for the .zip version of the module on #4, the option for "BEF settings" in the view edit interface stops working
I tried to apply the patch but it doesn´t seem to work, I get this:
Same thing when trying to patch better_exposed_filters 7.x-3.x-dev October 14, 2011 at 5:33pm
EDIT: by applying the patch manually (editing each file) i got it working although the option for "BEF settings" in the view edit interface does not work you can set the bef to "JQuery Slider" following the url: mysite/admin/structure/views/nojs/display/my_view/my_display/exposed_form_options
Comment #11
Peacog CreditAttribution: Peacog commentedI struggled with this for a while and finally figured out what to do to get this to work. You have to set the Filter identifier of your exposed filter to 'slider-filter'. The javascript applies the slider widget to form elements with id edit-slider-filter-min and edit-slider-filter-max. If it can't find those elements, it does nothing.
Here are the steps needed for D7 with BEF 7.x-3.0-beta3
1. Apply the patch. (I had to apply the .info chunk of the patch manually because it failed)
2. In your view go to the Filter Criteria section, select your exposed filter and scroll down to the More section. Open the More section and change the Filter identifier to slider-filter.
3. Go the Advanced view settings and set Exposed form style to Better Exposed Filters.
4. In BEF settings, select jQuery Slider as the display type for your exposed filter.
That's it.
Note, there's no need to download and install jquery ui or do any of the other stuff mentioned in the handbook page. jQuery UI comes bundled with D7, and the patch handles everything else.
Comment #12
Peacog CreditAttribution: Peacog commentedThere is a bug in the patch that causes the slider range to reset to min=0 and max=100 as soon as you move the slider. The bug is in better_exposed_filters.js where the slider is initialised. The min and max values are incorrectly set to sliderDefaults.init_min and sliderDefaults.init_max. Use the following code instead:
Comment #13
robcarrI've rerolled patch at #1 against latest DEV (8 Oct 12) because it completely failed to apply. Also added in the suggestions at #12.
There must be a better UI than changing the filter identifier name? Is there some other way of targeting the jQuery selector? Still not convinced that that this patch is ready, as the modal windows in Views UI don't seem to appear consistently since I applied the patch. This may well need a bit more work.
Comment #14
dgastudio CreditAttribution: dgastudio commentedand that if i want to have for example 4 sliders?
Comment #15
ngoquyen CreditAttribution: ngoquyen commented#1: better-exposed-filters-added-slider-1627524-1.patch queued for re-testing.
Comment #16
ticaasd CreditAttribution: ticaasd commentedmy slider didn't show up, but i've fixed...the big problem was that the i from "#edit-" + i + "-wrapper" uses has _ between words and the real id of the element uses -
the fix is after:
$.each(Drupal.settings.better_exposed_filters.defaults, function(i, sliderDefaults) {
addi=i.replace(/_/g,"-");
works like a charm!, (after u use display non on the real input)
thanks everyone!
edited: one more little fix:(i think this bug appears on ajax use only...)
change this:
to this:
the way it was setted up, after you was changeing the value and submited the form the max and min value gos to 0 and 100....
it didn't rememberd the initial value...this fix it
Comment #17
ticaasd CreditAttribution: ticaasd commentedComment #18
mikeker CreditAttribution: mikeker commentedThank you, everyone, for your work on this. Adding sliders to numeric filters is definitely on my roadmap for BEF.
However, this patch has several problems
We don't want to add BEF's JS code for all pages, just the ones that need it.
... And other lines: trailing spaces. As well as four-space indents through this section. I can't accept patches that don't follow the Drupal coding standards.
I haven't had a chance to look at the functionality of this patch -- I hope to do that tomorrow... There has been a major refactoring of how/when BEF options are presented to users so this patch may need a rerolled against the latest code.
My apologies for not getting to this issue sooner. I'll try and work on this in the very near future as I want to see jQuery sliders for all numeric filters in BEF.
Thanks.
Comment #19
rooby CreditAttribution: rooby commentedHere is a new version.
It fixes coding standards issues and has some changes to make the code fit in better with the code that is already in the module (some of which has recently changed since the previous patches).
There is also a couple of bug fixes.
I notice there is some javascript issue when editing filters sometimes, for which there is an issue at #1504560: Multiple Ajax Pagers Break jQuery Once that matches the symptoms.
I will do a bit more investigation later to see if it is caused in any way by this module.
This version also starts to add support for non-range/single value sliders for numeric fields that don't user BETWEEN, however that is a work in progress.
I will be continuing to work on this over the next few days, until it is all working well.
Todo:
* Handle the situation where min & max values are not entered for the exposed filter settings. I guess there is nothing to do except add default values like 0 & 1000000 or something. Any ideas on this one? Another option would be to just disable the slider entirely in the case min & max values are not present (this is what the old patch did).
* Handle non-BETWEEN numeric fields properly. This is limited by the same issue. Min and max values will need to be supplied by the admin or else we have to guess and put 0 & 1000000 or something.
* Lots more testing.
Comment #20
rooby CreditAttribution: rooby commentedMay as well run the test bot.
Comment #21
rooby CreditAttribution: rooby commentedMy solution for min & max values for range and single value sliders will be this:
I think the values set on the filter itself should not be used for min & max values.
This is because those fields are meant for default values.
So I will make min & max values additional settings in the BEF settings area.
This means you can have min & max values that are different to the default value, which is what you would want.
Next patch will have that set-up.
Comment #22
rooby CreditAttribution: rooby commentedHere is a new and more functional patch.
When you select jQuery slider or jQuery range slider as the widget you now get slider min & max values in the more options areas, which must be filled out.
The default filter value is use purely as a default and if no default value is set then the min & max values of the slider are used (or just the min if you are not using a range slider).
I have tested this with a number of sliders and range sliders on a single page and it is working for my tests (firefox).
This is pretty ready but I will do another review and possibly tidy up a couple of parts and do some more testing across different browsers later tonight.
Comment #23
rooby CreditAttribution: rooby commentedI did some cross browser testing and there are some issues with IE7 (mode in IE9) but they should be an easy fix.
I also realised it doesn't update the slider if you manually update the text field, only the other way around.
I will address those things tomight.
Comment #24
rooby CreditAttribution: rooby commentedHere is a new version with the following changes:
There is still the issue in IE7.
The problem is that the slider div is inside a div that is floating left (.views-exposed-widget) and there are no explicit widths set. IE does not like this and so horizontal sliders end up being extremely short. Vertical ones are ok.
I played around with an IE7 specific stylesheet to fix it but I haven't had luck getting a nice fix.
If there are any pro themers around who have a CSS fix feel free to make my life easier :)
I will also look into potentially making the blur functions (or at least part of them) a reusable function to stop similar code duplication.
Other than that this looks pretty good to me.
Actually there is one other thing.
It currently works on whole numbers and the slider increments by 1.
It might be useful to be able to set the step, and also allow decimal steps.
That would need the step setting, some tweaks to js code that currently forces whole numbers, and some extra validation for when manually editing fields, so that it snaps to the nearest step.
I will do that for the next version.
Comment #25
mikeker CreditAttribution: mikeker commentedrooby, Thank you for you work on this. I had a branch that I'd started playing around with adding sliders -- I've attached a diff but it's hardly complete. But it may be able to help you out with a few things -- who knows...
One approach I was thinking of, but hadn't implemented yet, was to give the user a textarea where they could specify any options to pass to the slider() init function. That would allow a lot of customization without adding a flurry of options to the BEF settings form.
Also, if you add any new BEF settings that are to be saved (eg: slider min/max values) you need to add them to the
$filter_defaults
array in_bef_get_settings()
so that users don't get undefined index warnings when they first start using the new code.Only had a chance to give the patch a quick read. I'll go through it in more details when time allows.
Thanks again!
Comment #26
rooby CreditAttribution: rooby commentedThanks for the patch, there is a few little things in there I might use.
I briefly thought about defaults but I figured it was not possible to be using the slider without configuring it (because you have to actively select it) so I put it on the back burner. I'll fix that in the next one.
As for the text area of options, there aren't that many options. My current patch already contains all but one of them.
The benefit of multiple settings is that it is much more user friendly, users don't have to look through and understand the docs, and we can more easily validate their selections.
The downside is there is a bit more code and new options have to be added when they arrive, however they are easy to add and I would imagine it will be rare that they are added.
Will make a new patch with a bunch of changes in the next day or so.
Comment #27
rooby CreditAttribution: rooby commentedHere is a new version that has had some refactoring.
I have simplified the way a couple of things worked and merged our 2 patches together.
I tried a few different versions of js to see which one was best and again ended up with bits from both our patches.
Tasks I know I still have to do:
I will do all that before the end of the week.
Comment #28
dgastudio CreditAttribution: dgastudio commentedbef, latest dev version
applied the patch..
can't found the way to make it work.
that i have to do?
Comment #29
rooby CreditAttribution: rooby commentedTo use:
1. Add exposed filter(s) to the view (it only works for number fields).
2. Go to the better exposed filters settings, in the "Exposed form" part of the "Advanced" settings.
3. In the "Exposed filter settings", select "jQuery UI slider" for your number filters.
4. Configure the slider settings for each filter its "More options for..." section, below where you selected "jQuery UI slider" (these settings may get split out into their own "Slider settings" fieldset in the next patch).
Comment #30
mikeker CreditAttribution: mikeker commentedrooby, Thank you for your continued work on this. I'm very excited to see this added to BEF.
You've hit the nail on the head. I'm worried about two things: 1) An overwhelming "additional options" section and 2) Keeping BEF up-to-date with options as they are added to various jQuery UI widgets. The second issue concerns not only slider widgets but all other jQUI widgets (eg: datepicker) that we may incorporate in BEF.
Perhaps the compromise would be to have some widget options baked into BEF (as you have done) and leave the rest as a textarea where users can override default values with whatever they want. Perhaps that makes everyone happy?
Comment #31
rooby CreditAttribution: rooby commentedYeah, I agree that there are a lot of settings.
My latest version (which I will post today) moves slider settings out of the "More options" area and into their own fieldset (as you had in the patch you posted), which I think helps some.
If we are to go for compromise, I would think it logical to have min, max & step as their own options (because they are the primary functionality) and the others (animate, orientation, whatever future options) in the text area.
Comment #32
rooby CreditAttribution: rooby commentedHere is a new version that adds the step setting and allows the use of decimals.
There are a few other fixes and cleanups also.
I have done some simple cross browser testing with and without the datepicker and it seems ok except for 2 things:
None of them are ideal really but I guess we have to choose one.
Comment #33
herd45 CreditAttribution: herd45 commentedI was only able to get the css and module file to update. I'm using Netbeans to apply the patch.
Comment #34
rooby CreditAttribution: rooby commentedHere is a re-roll of the patch in #32 that should apply cleanly over latest dev.
No functionality has been changed.
I have also included a zipped version of the module, which is latest dev checked out of git with the patch applied, just in case.
Comment #35
mikeker CreditAttribution: mikeker commentedrooby, Thanks for all your work on this! I've committed your latest patch. I'm willing to deal with (or won't fix, as the case may be for IE 7.x) items raised in #32 in other issues in the queue.
Awesome work! I'll buy you a beer if you make it up to DrupalCon Portland!
Comment #36
rooby CreditAttribution: rooby commentedNo worries, and thanks.
I will keep an eye out for any new bugs that might pop up and will make patches in new issues.
Also, my work on this functionality is sponsored by herd45
Comment #38
superdorx CreditAttribution: superdorx commentedHas this been committed to the latest dev?
Comment #39
rooby CreditAttribution: rooby commentedYes, see #35
Comment #40
mikeker CreditAttribution: mikeker commentedFYI, rooby, I added the slider option to the (very in-progress) handbook page of BEF options. I also added mention of your and herd45's participation/sponsorship. Please let me know (or edit the handbook page) if that is not preferred.
Comment #41
rooby CreditAttribution: rooby commentedThat's fine, thanks :)
Comment #42
herd45 CreditAttribution: herd45 commentedThanks mikeker
Comment #43
alex.87 CreditAttribution: alex.87 commentedIs there a way that we can lose this 2 input fields and have something similar to this
Comment #44
mikeker CreditAttribution: mikeker commentedYes, but that's up to the site designer/themer to handle. They can be hidden by CSS or JS (probably best to do with JS so they aren't hidden for folks that don't have JS enabled).
Comment #45
bsarchive CreditAttribution: bsarchive commentedIs there a way that the slider could be made to work with a part of an exposed date filter? I want to use it to select a range of years (e.g. 1926-1999) in a date field. So the year is numeric, but it's part of a date field.
?
Comment #46
bsarchive CreditAttribution: bsarchive commentedHi again, I'm having difficulty using the slider with an Openlayers map view. Using the latest .dev version, I can get the slider to work fine in a standard view (e.g. exposing NID as a filter) but as soon as I put the same exposed filter into an OL map view, the slider doesn't appear. The numeric field boxes (from... to...) are there but no slider.
Comment #47
rooby CreditAttribution: rooby commentedThis issue was for adding slider support and it has been completed.
Please open new issues for each of your new requests.
It is easier to keep track of everything that way.
Comment #48
Exploratus CreditAttribution: Exploratus commentedWorks great. Wanted to add that if someone wants to get the slider working on a mobile device so it drags on touch, they need to add / load the jquery touchpunch js. This will add touch functionality to all jquery ui elements, including the slider.
http://touchpunch.furf.com/
Thanks for the great work!
Comment #49
nicktr CreditAttribution: nicktr commentedThanks for the tip @Exploratus! Works like a charm!
Comment #50
ThuleNB CreditAttribution: ThuleNB commentedI don't want to open another issue as my questions related to this one. Unfortunately I am no coder, just having some css knowledge.
What exactly was commited here? From my newbie point of view I am not sure which steps for the "between slider" described in the handbook need to be done. Can I just follow the instructions in the handbook (+ comments for D7) or can I leave something out because of the fact that something is committed now?
Sounds like a silly question, but I'd be happy for any clarifications.
Comment #51
mikeker CreditAttribution: mikeker commented@ThuleNB: The BEF handbook pages need to be updated. What was checked in was the ability to use the jQuery sliders in Drupal core for numeric filters, either single value (greater/less than, equals, etc) or two-value (in between) settings. You set the greater/less/between in the filter settings (the operator dropdown) and set the slider options on the BEF settings form.
If that doesn't clarify things, you should probably open an issue requesting the documentation be updated.
Comment #52
ThuleNB CreditAttribution: ThuleNB commentedThanks Mike! That helps. However, I already did the setting as you described but the slider didn't appear, just the two boxes. I'll check my settings again and if applicable open a separate issue.
Comment #53
mafzalzadeh CreditAttribution: mafzalzadeh commentedI need to add slider on better exposed filter on drupal 8.
Is there any seggestion??
Comment #54
rooby CreditAttribution: rooby commented@mafzalzadeh I would do this:
This issue is very old and was specifically for the D7 feature. You won't have much luck with old closed off issues.