2

I am trying to load entries based on a date range that is selected by the user. On the front end of the site I have two input fields, the start day and end day of the date range. In the control panel, I have a custom date field (shipping_date), which is the field that will be compared to the inputted range.

What I would like is to pass those two dates inputted by the user into the channel entries tag in order to limit the entries to only ones where the shipping_date field is between the inputted date range. There are hundreds (if not thousands) of entries so I do not want to load all of them and then do the sorting on the front end.

So I guess my question is two fold:

  1. Can ExpressionEngine out of the box limit entries by a date range based on a custom date field? So far my research says this is not possible without an add-on (Low Search seems to be able to handle custom field date ranges)

  2. How do I pass inputted data from the user into either the channel entries tag or a plugin's tag?

Thank you in advance for any help!

  • Are you creating a form on the front-end for the user to submit two date ranges to return channel entries? – Miura-shi Feb 28 '18 at 19:12
  • @Miura-shi yes that's exactly what I am trying to do – Brianne Feb 28 '18 at 19:25
  • Did the Dynamic Parameters feature not suit your needs? Your case may be a little more complex but be sure to check it out: docs.expressionengine.com/latest/channel/… – Miura-shi Feb 28 '18 at 19:47
  • @Miura-shi I don't think that would work in this case for two reasons- I am using a custom date field rather than the entry date and while there is a start_on variable in the entries tag, I don't believe there is an ''end on" tag. If I'm wrong about that, please let me know! – Brianne Feb 28 '18 at 19:59
  • I haven't tested this personally but I think you're correct. You should also update your post to let everyone know what version of EE you're on. I currently only work with EE3 and 4. – Miura-shi Feb 28 '18 at 20:03
1

I'd suggest attempting to see if the start_on and stop_before parameters work for with Dynamic Parameters. Run a couple tests to see if this does not suit your needs or work first.

Dynamic Parameters Documentation

https://docs.expressionengine.com/v3/channel/dynamic_parameters.html

start_on documentation https://docs.expressionengine.com/v3/channel/channel_entries.html#start-on

stop_before documentation https://docs.expressionengine.com/v3/channel/channel_entries.html#stop-before

The next steps would be, if this does not suit your needs is to see if there is any module/add-on out their currently to handle more complex filtering like this. A site like https://devot-ee.com/

Out of the box, the EE channel entries tag is fairly linear and basic.

I typically write me own modules and use the Model service to query and filter front-end form submission input and return a custom tag pair. But this depends on your programming capabilities as well.

UPDATE

Sorry, I just remembered you said you're using a custom_field for the date, so out of the box the Dynamic Parameters will likely not work for you.

Please see if this post is helpful to you at all:

Show all entries from a given custom date field

| improve this answer | |
0

For anyone who comes across this answer now, there is an update to search:numeric_field='' parameter to now include a range in EE4. So you can use this parameter with a custom date field to search by range if you're using EE4.

Here's an article discussing the update: https://expressionengine.com/blog/three-new-content-filters-in-expressionengine-4

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.