Skip to content

Commit 4a4c27f

Browse files
committed
allow view blog dates by year instead of only year/month
1 parent 9de1931 commit 4a4c27f

6 files changed

Lines changed: 71 additions & 32 deletions

File tree

changes-v271.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Version 2.7.1 - Specific changes from previous version
1111
- expHtmlToPDF support for Dompdf v2+
1212
- add do-not-index indicator to manage pages by sitemap status
1313
- set email reply-to to actual sender when smtp send requires smtp username
14+
- allow blog categories url by sef_url instead of only id
15+
- allow view blog date url by year instead of only year/month
1416

1517
### v271 fixes these issues in v270 and previous patches:
1618
- change default pdf output from A4 to Letter
@@ -23,7 +25,8 @@ Version 2.7.1 - Specific changes from previous version
2325
- regression fix pagination ribbon when sorting by category to trim total records
2426
- regression fix aggregation anomaly prevented blog post next/prev links
2527
- regression fix (v270p1) new bs5 datepicker not passing good date
26-
-
28+
- fix issue where group selected expCats array wasn't reindexed
29+
2730
### v271 updates these 3rd party libraries in v270 and previous patches:
2831
- bootstrap-icons to v1.10.3
2932
- EmailValidator to v3.2.4

framework/modules/blog/controllers/blogController.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,15 @@ public function dates() {
153153

154154
public function showall_by_date() {
155155
expHistory::set('viewable', $this->params, true);
156-
$start_date = expDateTime::startOfMonthTimestamp(mktime(0, 0, 0, $this->params['month'], 1, $this->params['year']));
157-
$end_date = expDateTime::endOfMonthTimestamp(mktime(23, 59, 59, $this->params['month'], 1, $this->params['year']));
156+
if (isset($this->params['month'])) {
157+
$start_date = expDateTime::startOfMonthTimestamp(mktime(0, 0, 0, $this->params['month'], 1, $this->params['year']));
158+
$end_date = expDateTime::endOfMonthTimestamp(mktime(23, 59, 59, $this->params['month'], 1, $this->params['year']));
159+
$period = expDateTime::format_date($start_date,"%B %Y");
160+
} else {
161+
$start_date = expDateTime::startOfYearTimestamp(mktime(0, 0, 0, 1, 1, $this->params['year']));
162+
$end_date = expDateTime::endOfYearTimestamp(mktime(23, 59, 59, 12, 1, $this->params['year']));
163+
$period = expDateTime::format_date($start_date,"%Y");
164+
}
158165

159166
$page = new expPaginator(array(
160167
'model'=>$this->basemodel_name,
@@ -173,7 +180,7 @@ public function showall_by_date() {
173180

174181
assign_to_template(array(
175182
'page'=>$page,
176-
'moduletitle'=>gt('Blogs by date').' "'.expDateTime::format_date($start_date,"%B %Y").'"')
183+
'moduletitle'=>gt('Blogs by date').' "'.$period.'"')
177184
);
178185
}
179186

framework/modules/blog/views/blog/dates.tpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
{$config.moduledescription}
2020
{/if}
2121
{foreach from=$dates item=ydate key=year}
22-
<h3>{$year}</h3>
22+
<h3>
23+
<a href="{link action=showall_by_date year=$year}" title='{"View all posts from"|gettext} {$year}'>{$year}</a>
24+
</h3>
2325
<ul>
2426
{foreach from=$ydate item=mdate key=month}
2527
<li>

themes/bootstrap3theme/router_maps.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@
6060
// ),
6161
//);
6262

63-
// Find blog post by the title. URL would look like blog/my-post-title
64-
//$maps[] = array(
65-
// 'controller' => 'blog',
66-
// 'action' => 'show',
67-
// 'url_parts' => array(
68-
// 'controller' => 'blog',
69-
// 'title' => '(.*)'
70-
// ),
71-
//);
7263
// Find blog posts by the tag. URL would look like view-blogs-by-tag/my-tag
7364
//$maps[] = array(
7465
// 'controller' => 'blog',
@@ -88,6 +79,24 @@
8879
// 'month' => '[01]?\d',
8980
// ),
9081
//);
82+
// Find blog posts by date, year. URL would look like blog/2019 to display all posts in 2019
83+
//$maps[] = array(
84+
// 'controller' => 'blog',
85+
// 'action' => 'showall_by_date',
86+
// 'url_parts' => array(
87+
// 'controller' => 'blog',
88+
// 'year' => '(19|20)\d\d',
89+
// ),
90+
//);
91+
// Find blog post by the title. URL would look like blog/my-post-title
92+
//$maps[] = array(
93+
// 'controller' => 'blog',
94+
// 'action' => 'show',
95+
// 'url_parts' => array(
96+
// 'controller' => 'blog',
97+
// 'title' => '(.*)'
98+
// ),
99+
//);
91100
// Find blog posts by author. URL would look like view-blogs-by-author/author-username
92101
//$maps[] = array(
93102
// 'controller' => 'blog',

themes/bootstrap4theme/router_maps.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@
6060
// ),
6161
//);
6262

63-
// Find blog post by the title. URL would look like blog/my-post-title
64-
//$maps[] = array(
65-
// 'controller' => 'blog',
66-
// 'action' => 'show',
67-
// 'url_parts' => array(
68-
// 'controller' => 'blog',
69-
// 'title' => '(.*)'
70-
// ),
71-
//);
7263
// Find blog posts by the tag. URL would look like view-blogs-by-tag/my-tag
7364
//$maps[] = array(
7465
// 'controller' => 'blog',
@@ -88,6 +79,24 @@
8879
// 'month' => '[01]?\d',
8980
// ),
9081
//);
82+
// Find blog posts by date, year. URL would look like blog/2019 to display all posts in 2019
83+
//$maps[] = array(
84+
// 'controller' => 'blog',
85+
// 'action' => 'showall_by_date',
86+
// 'url_parts' => array(
87+
// 'controller' => 'blog',
88+
// 'year' => '(19|20)\d\d',
89+
// ),
90+
//);
91+
// Find blog post by the title. URL would look like blog/my-post-title
92+
//$maps[] = array(
93+
// 'controller' => 'blog',
94+
// 'action' => 'show',
95+
// 'url_parts' => array(
96+
// 'controller' => 'blog',
97+
// 'title' => '(.*)'
98+
// ),
99+
//);
91100
// Find blog posts by author. URL would look like view-blogs-by-author/author-username
92101
//$maps[] = array(
93102
// 'controller' => 'blog',

themes/bootstrap5theme/router_maps.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@
6060
// ),
6161
//);
6262

63-
// Find blog post by the title. URL would look like blog/my-post-title
64-
//$maps[] = array(
65-
// 'controller' => 'blog',
66-
// 'action' => 'show',
67-
// 'url_parts' => array(
68-
// 'controller' => 'blog',
69-
// 'title' => '(.*)'
70-
// ),
71-
//);
7263
// Find blog posts by the tag. URL would look like view-blogs-by-tag/my-tag
7364
//$maps[] = array(
7465
// 'controller' => 'blog',
@@ -88,6 +79,24 @@
8879
// 'month' => '[01]?\d',
8980
// ),
9081
//);
82+
// Find blog posts by date, year. URL would look like blog/2019 to display all posts in 2019
83+
//$maps[] = array(
84+
// 'controller' => 'blog',
85+
// 'action' => 'showall_by_date',
86+
// 'url_parts' => array(
87+
// 'controller' => 'blog',
88+
// 'year' => '(19|20)\d\d',
89+
// ),
90+
//);
91+
// Find blog post by the title. URL would look like blog/my-post-title
92+
//$maps[] = array(
93+
// 'controller' => 'blog',
94+
// 'action' => 'show',
95+
// 'url_parts' => array(
96+
// 'controller' => 'blog',
97+
// 'title' => '(.*)'
98+
// ),
99+
//);
91100
// Find blog posts by author. URL would look like view-blogs-by-author/author-username
92101
//$maps[] = array(
93102
// 'controller' => 'blog',

0 commit comments

Comments
 (0)