Forums › Forums › Search & Filter Pro › Negative value range – Slider
Tagged: V3
- This topic has 8 replies, 2 voices, and was last updated 3 years, 10 months ago by Anonymous.
-
Anonymous(Private) February 21, 2018 at 12:28 pm #161208
Is it possible to use a negative value when using the ‘Range – Slider’ input type. I ask because it only seems to work when the min value is ‘0’ and not below ‘0’. I would like the range to be ‘-35’ to ‘300’.
This is how I’ve set it up:
Input type: Range – Slider
Display values as: Input Field
Start Meta Key: temperature_resistance / temperature_resistance_max
Compare Mode: Post Meta must be within input range
Min Value: Auto Detect
Max Value: Auto DetectFor some reason it will not show when the first value is below ‘0’.
Can someone help with this?
Ross Moderator(Private) March 27, 2018 at 9:28 pm #168645Hi Jarno
Sorry for the delay on this – I’ll update tomorrow.
Thanks
Anonymous(Private) February 5, 2021 at 5:04 pm #275392I know this is an old post, but someone might be helped by my findings.
The problem with the range slider using negative number is caused by the filtering code casting the values to UNSIGNED, thus making the negative numbers positive before the comparision.If you open the files includes/fields/post_meta_choice.php and public/includes/class-search-filter-cache.php and search for UNSIGNED and replace it with SIGNED (and upload to your server), the filtering will also work with negative numbers.
Ross Moderator(Private) February 5, 2021 at 5:26 pm #275395Awesome fine Stefan!
We have tested with negative and I thought it was working, perhaps a different effect is triggered in different environments?
Anyway, I’ll do some digging and hope to then add this to the next release.
Best
Anonymous(Private) February 6, 2021 at 12:08 am #275437Hi Ross,
if you use only negative numbers, everything will work fine because all numbers are made positive before the comparision
But in my case, the facet search range was for example -2000 till +1000 and I have a setup with a start field and an end field in my post type. The Compare Mode is set to ‘Post Meta must be within input range’.
A post with a start value of -400 and end value of +200 should be returned by the query. But if the values are cast to an UNSIGNED int, we check if +200 to +400 fals in the range of +1000 to +2000 and it is incorrectly removed from the search results.
Hope that makes sense.Cheers,
Stfan -
AuthorPosts