a-ok Posted October 3, 2017 Share Posted October 3, 2017 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 More sharing options...
abdus Posted October 3, 2017 Share Posted October 3, 2017 You want find() not filter() (I don't think it even exists) Link to comment Share on other sites More sharing options...
a-ok Posted October 3, 2017 Author Share Posted October 3, 2017 2 minutes ago, abdus said: You want find() not filter() (I don't think it even exists) Thanks. It does exist (http://cheatsheet.processwire.com/pagearray-wirearray/sorting-and-filtering/a-filter-selector/) in this context (pageField returns an array) BUT it looks like it doesn't support 'today' so looks like I have to use time(); instead. 1 Link to comment Share on other sites More sharing options...
abdus Posted October 3, 2017 Share Posted October 3, 2017 'today' should have worked, 'now' also works. But using strtotime() is the most intuitive one 1 Link to comment Share on other sites More sharing options...
a-ok Posted October 3, 2017 Author Share Posted October 3, 2017 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 More sharing options...
BitPoet Posted October 3, 2017 Share Posted October 3, 2017 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. 3 Link to comment Share on other sites More sharing options...
Robin S Posted October 3, 2017 Share Posted October 3, 2017 2 hours ago, oma said: I thought it should've worked too as long as it's inside a selector A bit more about this... 3 Link to comment Share on other sites More sharing options...
a-ok Posted October 4, 2017 Author Share Posted October 4, 2017 Thanks for the information and help as always! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now