Fix blog archive widget bug

Fixes blog archive widget bug to only get the archive months for the blog linked to in this widget.
This commit is contained in:
3Dgoo 2018-06-26 13:17:47 +09:30 committed by Robbie Averill
parent ec116870f5
commit 01c1ead069
1 changed files with 5 additions and 1 deletions

View File

@ -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();