From 01c1ead069825c383fd31e72b35d835da65be558 Mon Sep 17 00:00:00 2001 From: 3Dgoo Date: Tue, 26 Jun 2018 13:17:47 +0930 Subject: [PATCH] Fix blog archive widget bug Fixes blog archive widget bug to only get the archive months for the blog linked to in this widget. --- src/Widgets/BlogArchiveWidget.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Widgets/BlogArchiveWidget.php b/src/Widgets/BlogArchiveWidget.php index 878450f..f3a3763 100644 --- a/src/Widgets/BlogArchiveWidget.php +++ b/src/Widgets/BlogArchiveWidget.php @@ -124,7 +124,11 @@ class BlogArchiveWidget extends Widget $query = SQLSelect::create($fields, '"BlogPost' . $suffix . '"') ->addGroupBy($publishDate) ->addOrderBy('"PublishDate" DESC') - ->addWhere(['"PublishDate" <= ?' => DBDatetime::now()->Format(DBDatetime::ISO_DATETIME)]); + ->addLeftJoin('SiteTree' . $suffix, '"SiteTree' . $suffix . '"."ID" = "BlogPost' . $suffix . '"."ID"') + ->addWhere([ + '"PublishDate" <= ?' => DBDatetime::now()->Format(DBDatetime::ISO_DATETIME), + 'SiteTree' . $suffix . '.ParentID' => $this->BlogID, + ]); $posts = $query->execute(); $result = ArrayList::create();