mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
BUGFIX: #1709 - Archive widgets shows months and years for unpublished posts
This commit is contained in:
parent
bbba843ba5
commit
2bcbb8ee7d
@ -52,10 +52,14 @@ class ArchiveWidget extends Widget {
|
||||
$blogHolder = $this->getBlogHolder();
|
||||
$id = $blogHolder->ID;
|
||||
|
||||
$stage = Versioned::current_stage();
|
||||
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
|
||||
|
||||
|
||||
if($this->DisplayMode == 'month') {
|
||||
$sqlResults = DB::query("SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year` FROM `SiteTree` NATURAL JOIN `BlogEntry` WHERE `ParentID` = $id ORDER BY `Date` DESC");
|
||||
$sqlResults = DB::query("SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year` FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix` WHERE `ParentID` = $id ORDER BY `Date` DESC");
|
||||
} else {
|
||||
$sqlResults = DB::query("SELECT DISTINCT YEAR(`Date`) AS `Year` FROM `SiteTree` NATURAL JOIN `BlogEntry` WHERE `ParentID` = $id ORDER BY `Date` DESC");
|
||||
$sqlResults = DB::query("SELECT DISTINCT YEAR(`Date`) AS `Year` FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix` WHERE `ParentID` = $id ORDER BY `Date` DESC");
|
||||
}
|
||||
|
||||
if(!$sqlResults) return new DataObjectSet();
|
||||
|
Loading…
Reference in New Issue
Block a user