Permalink
Browse files

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

ENHANCEMENT: added action on BlogTree
  • Loading branch information...
1 parent 9cfd303 commit d491c442dcdfbb60ff51530398eb5f96cfa8f61a @cbarberis cbarberis committed Jul 1, 2010
Showing with 23 additions and 7 deletions.
  1. +21 −5 code/BlogTree.php
  2. +1 −1 templates/Layout/BlogHolder.ss
  3. +1 −1 templates/Layout/BlogTree.ss
View
@@ -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));
+ }
+ }
}
@@ -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 %>
@@ -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 %>

0 comments on commit d491c44

Please sign in to comment.