mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
ENHANCEMENT: Added option to view archives just by year (ticket #5667)
ENHANCEMENT: added action on BlogTree
This commit is contained in:
parent
9cfd303ecf
commit
d491c442dc
@ -210,7 +210,8 @@ class BlogTree_Controller extends Page_Controller {
|
|||||||
static $allowed_actions = array(
|
static $allowed_actions = array(
|
||||||
'index',
|
'index',
|
||||||
'rss',
|
'rss',
|
||||||
'tag'
|
'tag',
|
||||||
|
'date'
|
||||||
);
|
);
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@ -255,7 +256,7 @@ class BlogTree_Controller extends Page_Controller {
|
|||||||
|
|
||||||
$date = $this->SelectedDate();
|
$date = $this->SelectedDate();
|
||||||
|
|
||||||
return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date->Format('Y-m') : '', null, $filter);
|
return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date : '', null, $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -311,13 +312,28 @@ class BlogTree_Controller extends Page_Controller {
|
|||||||
$month = $this->request->latestParam('OtherID');
|
$month = $this->request->latestParam('OtherID');
|
||||||
|
|
||||||
if(is_numeric($year) && is_numeric($month) && $month < 13) {
|
if(is_numeric($year) && is_numeric($month) && $month < 13) {
|
||||||
$date = new Date();
|
|
||||||
$date->setValue($year .'-'. $month);
|
|
||||||
|
|
||||||
|
$date = $year .'-'. $month;
|
||||||
return $date;
|
return $date;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(is_numeric($year)) return $year;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function SelectedNiceDate(){
|
||||||
|
$date = $this->SelectedDate();
|
||||||
|
|
||||||
|
if(strpos($date, '-')) {
|
||||||
|
$date = explode("-",$date);
|
||||||
|
return date("F", mktime(0, 0, 0, $date[1], 1, date('Y'))). " " .date("Y", mktime(0, 0, 0, date('m'), 1, $date[0]));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return date("Y", mktime(0, 0, 0, date('m'), 1, $date));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@
|
|||||||
<% if SelectedTag %>
|
<% if SelectedTag %>
|
||||||
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'</h3>
|
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'</h3>
|
||||||
<% else_if SelectedDate %>
|
<% else_if SelectedDate %>
|
||||||
<h3><% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedDate.Month $SelectedDate.Year</h3>
|
<h3><% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedNiceDate</h3>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% if BlogEntries %>
|
<% if BlogEntries %>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<% if SelectedTag %>
|
<% if SelectedTag %>
|
||||||
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'</h3>
|
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'</h3>
|
||||||
<% else_if SelectedDate %>
|
<% else_if SelectedDate %>
|
||||||
<h3><% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedDate.Month $SelectedDate.Year</h3>
|
<h3><% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedNiceDate</h3>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% if BlogEntries %>
|
<% if BlogEntries %>
|
||||||
|
Loading…
Reference in New Issue
Block a user