Jump to content

Date range selector with potentially undefined boundaries


Ivan Gretsky
 Share

Recommended Posts

Hello!

I need to show pages with date range publish limitation. I mean each page has date_start and date_end fields, that, if populated, should determine, whether the page is considered "published" today. But none of those fields is mandatory. You can fill one or the other or both.

I have written a selector with OR-groups like this:

$selector = "SOME-CONDITION-HERE, ";
$selector .= "range=(date_start='', date_end=''), ";
$selector .= "range=(date_start='', date_end>=today), ";
$selector .= "range=(date_start<=today, date_end>=today), ";
$selector .= "range=(date_start<=today, date_end='')";

But is seems a little ugly and over-complicated. I thought maybe someone could propose a better solution? If not, let it be a working example of how to deal with this)

Link to comment
Share on other sites

We've been doing basically the same thing but like this:

$selector .= ", has_started=(start_date=''), has_started=(start_date<=today)";
$selector .= ", not_ended=(end_date=''), not_ended=(end_date>today)";

It seems to work ok. I don’t know of an easier way.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...