mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
MINOR: added datetime helper function
This commit is contained in:
parent
2a9ea56c39
commit
54b1c07049
@ -51,16 +51,18 @@ class ArchiveWidget extends Widget {
|
||||
$stage = Versioned::current_stage();
|
||||
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
|
||||
|
||||
$monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') . ' * 1' : 'MONTH("Date")';
|
||||
$yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
|
||||
if($this->DisplayMode == 'month') {
|
||||
$sqlResults = DB::query("
|
||||
SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\"
|
||||
SELECT DISTINCT $monthclause AS \"Month\", $yearclause AS \"Year\"
|
||||
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
|
||||
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
|
||||
ORDER BY \"Year\" DESC, \"Month\" DESC;"
|
||||
);
|
||||
} else {
|
||||
$sqlResults = DB::query("
|
||||
SELECT DISTINCT YEAR(\"Date\") AS \"Year\"
|
||||
SELECT DISTINCT $yearclause AS \"Year\"
|
||||
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
|
||||
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
|
||||
ORDER BY \"Year\" DESC"
|
||||
|
Loading…
Reference in New Issue
Block a user