1

I have a section of 'deals/coupons' with custom startDate and endDate. These are needed so the client can load up a bunch of deals but only have them render to the page when a particular deal is 'active'.

The below syntax works to not show any deal before it's startdate has passed:

{% paginate craft.entries({
   section : 'dealDirectory',
   limit   : pageSize,
   startDate : '<=' ~ now
}) as pageInfo, dealEntries %}

And using the below code I can prevent deals from showing after their enddate but only if enddate has data:

{% paginate craft.entries({
   section : 'dealDirectory',
   limit   : pageSize,
   startDate : '<=' ~ now
   endDate : '>=' ~ now
}) as pageInfo, dealEntries %}

If enddate does not have a value it eliminates those entries from showing. I need to find a way to check if enddate is greater than now OR is null so that it will continue to show deals that do not have an enddate. Such as:

{% paginate craft.entries({
   section : 'dealDirectory',
   limit   : pageSize,
   startDate : '<=' ~ now
   endDate   : '>= ' ~ now ~ 'or is null'  // but this syntax incorrect
}) as pageInfo, dealEntries %}

I'm having a hard time finding a reference for this type of markup.

1

Shooting in the dark here, but looking off this ticket and the ECM parameter value syntax in the docs, could you do something like:

{% paginate craft.entries({
    section : 'dealDirectory',
    limit   : pageSize,
    startDate : '<=' ~ now
    endDate: 'or', '>= ' ~ now, 'not null'
}) as pageInfo, dealEntries %}

The or is a total guess based on the and in the other ticket.

  • @fattybeardface curious to know if this worked, or what was your final outcome? Did you get it sorted? – Ryan Sep 18 '17 at 21:07

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.