Forums › Forums › Search & Filter Pro › Annual/Monthly Archive Dropdown Filter
- This topic has 4 replies, 3 voices, and was last updated 9 years, 3 months ago by
Anonymous.
-
Trevor(Private) March 26, 2016 at 8:34 am #40582
Ross may wish to chime in here, but as I am awake this early, I will answer by way of a rambling of my initial thoughts, if I may?
Dates (such as ‘post date’) are not stored in databases the way we read them. Instead they are typically stored as days and fractions of days. So day 0 might be 01/01/1900, day 1 might then be 01/02/1900 and so on. To find the year the system has to first convert the days stored to a date that we understand, extract the year part and give us that. That places an overhead on the system. So, instead, lets us say we want to see all posts from 2014. 01/01/2014 is day 41640 and 12/31/2014 is day 42004 so what we ask the database to do is to find all posts with
'post date' >= 41640 && <= 42004
The S&F Pro Post Date does not have the option to extract, sort and collate just the years, and the CPU overhead for this at page load/reload might be an issue.
You could set the Post Date element to Date range and then hide it by using this custom code:
.sf_date_field {display: none;}
And then use Javscript to replace the field title that you had set, say maybe
<h4>Date</h4>
or whatever with a selects for the date that the javascript pre-fills with years in the visible part but whose values are January 1 of that year. When the field is changed by the user, another script copies that start date to the hidden form’s start date, then works out from that date what the year end date is and copies that to the hidden end date form control and then triggers the S&F update form function.A bit messy for what seems a ‘simple’ request!!
Just my thoughts …..
Anonymous(Private) March 26, 2016 at 6:54 pm #40596Hello, I just spotted this as it’s also an option I have requested too : https://support.searchandfilter.com/forums/topic/post-date-year-month-only-dropdowns/ as it would be ever so useful. Your response Trevor suggests it could be more problematic to integrate than I had hoped in terms of considering this as a future update which is such a shame. I suppose it’s over to Ross now :).
Trevor(Private) March 27, 2016 at 7:54 am #40604I think it could be done in code in S&F without too much effort; the only thing slowing it down would be the need to find the oldest year, but maybe this could be resolved by the designer manually defining that.
I think, as you say, this would be for Ross to consider.
-
AuthorPosts