Forums Forums Search & Filter Pro Annual/Monthly Archive Dropdown Filter

Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #40571

    Hello,

    We are using the shortcode method to display press releases and news on a client website. The client wants two filter drop-downs: one for the news item category, and the other to filter posts by year.

    The “Post Date” field seems to be the closest, but they don’t want to have a whole calendar pop up that has to be navigated. They would just like a simple list of years, so they can see what was posted in 2015, for example.

    Is this possible? I’ve searched the forums and documentation, and can’t seem to find anything that specifically addresses this functionality.

    Thank you!
    John

    Trevor
    #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
    #40596

    Hello, 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
    #40604

    I 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.

    Anonymous
    #40607

    Thank you for your reply Trevor, I just wanted to say that certainly from my perspective I wouldn’t have any problem in setting the Start Year if Ross was to consider this functionality :).

Viewing 5 posts - 1 through 5 (of 5 total)