From 27044d86a52b8113a0f447e658feafad3d7b6435 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 22 Sep 2017 14:54:44 +1200 Subject: [PATCH] FIX Display individual years in blog archive widget when set to "Yearly" --- code/widgets/BlogArchiveWidget.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/widgets/BlogArchiveWidget.php b/code/widgets/BlogArchiveWidget.php index e6b7b8f..6fc4695 100644 --- a/code/widgets/BlogArchiveWidget.php +++ b/code/widgets/BlogArchiveWidget.php @@ -105,14 +105,15 @@ class BlogArchiveWidget extends Widget $posts = $query->execute(); $result = new ArrayList(); while ($next = $posts->next()) { - $date = Date::create(); - $date->setValue(strtotime($next['PublishDate'])); - $year = $date->Format('Y'); - if ($this->ArchiveType == 'Yearly') { + $year = $next['PublishDate']; $month = null; $title = $year; } else { + $date = Date::create(); + $date->setValue(strtotime($next['PublishDate'])); + + $year = $date->Format('Y'); $month = $date->Format('m'); $title = $date->FormatI18N('%B %Y'); }