Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENHANCEMENT: Added option to view archives just by year (ticket #5667)

ENHANCEMENT: added action on BlogTree
  • Loading branch information...
commit d491c442dcdfbb60ff51530398eb5f96cfa8f61a 1 parent 9cfd303
@cbarberis cbarberis authored
View
26 code/BlogTree.php
@@ -210,7 +210,8 @@ class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
'index',
'rss',
- 'tag'
+ 'tag',
+ 'date'
);
function init() {
@@ -255,7 +256,7 @@ function BlogEntries($limit = null) {
$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 @@ function SelectedDate() {
$month = $this->request->latestParam('OtherID');
if(is_numeric($year) && is_numeric($month) && $month < 13) {
- $date = new Date();
- $date->setValue($year .'-'. $month);
-
+
+ $date = $year .'-'. $month;
return $date;
+
+ } else {
+
+ if(is_numeric($year)) return $year;
}
}
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));
+ }
+ }
}
View
2  templates/Layout/BlogHolder.ss
@@ -7,7 +7,7 @@
<% if SelectedTag %>
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'</h3>
<% 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 %>
<% if BlogEntries %>
View
2  templates/Layout/BlogTree.ss
@@ -7,7 +7,7 @@
<% if SelectedTag %>
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'</h3>
<% 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 %>
<% if BlogEntries %>
Please sign in to comment.
Something went wrong with that request. Please try again.