Kirby 2.2 Filter By Time Not Working

So, I’ve got this in my controller for a template:

$letters = $pages->find('letters')->children()->filterBy('date', '<=', time());

date is a metadata field that contains a date to publish the page (e.g. 2015-11-25). In this way, I could schedule pages to publish in the future.

In past versions of Kirby, $letters would correctly return a collection that excluded pages with a date field that was set in the future. However, with Kirby 2.2, it no longer excludes those pages — the collection returned includes every single page, regardless of what I have in the date field.

Nothing else has changed on my end except for the update to 2.2. Also, filterBy() seems to work properly for filtering with a string. It’s just when I’m filtering against time() that it malfunctions.

Ahh I’m afraid this is caused by a change of the date method in 2.2 (it now returns a Field object). Will have a closer look at it tomorrow to find a workaround or fix.

1 Like

Will be fixed shortly in an updated release.

Fixed in 2.2.1! Thanks guys — that was fast! :grinning:

1 Like