Search for predefined date ranges
Hi,
How would I create a drop-down that has the following options for Low Search:
Entries created in the last 7 days
Entries created in the last month
etc.
Thanks in advance.
Hi,
How would I create a drop-down that has the following options for Low Search:
Entries created in the last 7 days
Entries created in the last month
etc.
Thanks in advance.
Replies
Low 2 Dec 2013 17:22
You'd have to use the native start_on/stop_before parameters: http://ellislab.com/expressionengine/...
LS doesn't provide a way to automate the generation of the drop down, so you'd have to use either a custom query or hard code it. Or use PHP in your template to generate it..
Nick 2 Dec 2013 18:34
Ok, thanks Low.
Nick 3 Dec 2013 21:11
Sorry Low, still not quite clear on this.
I'm using PHP in my template. This works fine, it's the populating of the options that has vexed me. The following shows me the results of the exp:channel:entries pair (last 7 days of entries) instead of allowing me to select that criteria in order to perform a search (which is what I want):
Where have I gone wrong?
Low 4 Dec 2013 08:16
Couple of things. You're using "range:entry_date", which implies you're targeting the channel field "entry_date" with a range, which should have a start and end date/time. That's not what you're after, I presume.
Instead, because Low Search can dynamically set all native parameters, including the start_on="" parameter, that is what you need to target, using the value you generate with PHP. That would come down to something like this:
Make sense?
Nick 4 Dec 2013 13:05
Ah, that makes perfect sense! Thank you for your reply.
CNG 6 Apr 2014 13:20
I don’t suppose there’s an easy way to do this targeting the 'edit_date' instead of 'entry_date' as 'start_on' seems to use?
Low 6 Apr 2014 13:24
Not at the moment, no. There doesn't appear to be a native parameter that targets the edit_date. I do have an item in my todo list to make native global EE fields like entry_date compatible with the Ranges filter. No ETA on that one, tho.
CNG 6 Apr 2014 13:26
All right, thanks. I’m trying to flesh out all the possible sorting options I can provide to make a large library more approachable for end users... hence all the questions. :-)
Low 6 Apr 2014 13:27
Sorting by edit_date shouldn't be a problem. Filtering by that field, however, is currently not possible out of the box.