Jump to content

Filter out past events when using pageReference field (front end)


a-ok
 Share

Recommended Posts

I have a pageReference field which the client is then picking/choosing events. In case the client forgets to take off past events I wanted to ensure that events whose start date is greater than today would be filtered out.

Any thoughts? I thought the below would work but it's returning nothing. If I remove the filter it returns all the pages chosen by the pageReference field... so it's something to do with my filter.

$events = $page->our_picks_events->filter("events_detail_dates_start_date>today")->sort("events_detail_dates_start_date, name");

 

Link to comment
Share on other sites

I thought it should've worked too as long as it's inside a selector... but alas it didn't. Using time() does the trick, though. And yep strtotime("now") works too so I'll use that instead.

Maybe it's a bug? Hard to see how it could be as it's within a filter selector.

Link to comment
Share on other sites

1 hour ago, oma said:

I thought it should've worked too as long as it's inside a selector

As far as I recall, today as a literal only works in database selectors, i.e. calls to $pages->find and the likes, not in operations on WireArrays. Not sure if this is documented anywhere though.

  • Like 3
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...