From 7ca7d8e045521794af0c43fcb0a81da7db1084d1 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 7 May 2021 13:23:38 +0300 Subject: [PATCH] Allow optional start date in page collections [#3350] --- CHANGELOG.md | 4 +++- system/src/Grav/Common/Flex/Types/Pages/PageCollection.php | 4 ++-- system/src/Grav/Common/Page/Collection.php | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb5589a8f..c289d7a8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # v1.7.15 ## mm/dd/2021 +1. [](#improved) + * Allow optional start date in page collections [#3350](https://github.com/getgrav/grav/pull/3350) 1. [](#bugfix) * Fixed twig deprecated TwigFilter messages [#3348](https://github.com/getgrav/grav/issues/3348) * Fixed fatal error with some markdown links [grav-premium-issues#95](https://github.com/getgrav/grav-premium-issues/issues/95) - * Fixed markdown media operations not working when using `image:// stream` [#3333](https://github.com/getgrav/grav/issues/3333) [#3349](https://github.com/getgrav/grav/issues/3349) + * Fixed markdown media operations not working when using `image://` stream [#3333](https://github.com/getgrav/grav/issues/3333) [#3349](https://github.com/getgrav/grav/issues/3349) # v1.7.14 ## 04/29/2021 diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php index 781d25afe..cdd609bcd 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageCollection.php @@ -438,8 +438,8 @@ class PageCollection extends FlexPageCollection implements PageCollectionInterfa */ public function dateRange($startDate = null, $endDate = null, $field = null) { - $start = $startDate ? Utils::date2timestamp($startDate) : false; - $end = $endDate ? Utils::date2timestamp($endDate) : false; + $start = $startDate ? Utils::date2timestamp($startDate) : null; + $end = $endDate ? Utils::date2timestamp($endDate) : null; $entries = []; foreach ($this as $key => $object) { diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php index 643f8516a..83013fb17 100644 --- a/system/src/Grav/Common/Page/Collection.php +++ b/system/src/Grav/Common/Page/Collection.php @@ -331,14 +331,14 @@ class Collection extends Iterator implements PageCollectionInterface */ public function dateRange($startDate = null, $endDate = null, $field = null) { - $start = $startDate ? Utils::date2timestamp($startDate) : false; - $end = $endDate ? Utils::date2timestamp($endDate) : false; + $start = $startDate ? Utils::date2timestamp($startDate) : null; + $end = $endDate ? Utils::date2timestamp($endDate) : null; $date_range = []; foreach ($this->items as $path => $slug) { $page = $this->pages->get($path); if (!$page) { - continue ; + continue; } $date = $field ? strtotime($page->value($field)) : $page->date();