Skip to content

Commit f6b7c2e

Browse files
committed
bug #1136 bug #1135 Fix pagination with tag filter (jkufner)
This PR was merged into the master branch. Discussion ---------- bug #1135 Fix pagination with tag filter See #1135 Commits ------- bfc2e9c bug #1135 Fix pagination with tag filter
2 parents 68681d0 + bfc2e9c commit f6b7c2e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Controller/BlogController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function index(Request $request, int $page, string $_format, PostReposito
5959
// See https://symfony.com/doc/current/templates.html#template-naming
6060
return $this->render('blog/index.'.$_format.'.twig', [
6161
'paginator' => $latestPosts,
62+
'tagName' => $tag ? $tag->getName() : null,
6263
]);
6364
}
6465

templates/blog/index.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div class="navigation text-center">
2929
<ul class="pagination">
3030
{% if paginator.hasPreviousPage %}
31-
<li class="prev"><a href="{{ path('blog_index_paginated', {page: paginator.previousPage}) }}" rel="previous"><i class="fa fw fa-long-arrow-left"></i> {{ 'paginator.previous'|trans }}</a></li>
31+
<li class="prev"><a href="{{ path('blog_index_paginated', {page: paginator.previousPage, tag: tagName}) }}" rel="previous"><i class="fa fw fa-long-arrow-left"></i> {{ 'paginator.previous'|trans }}</a></li>
3232
{% else %}
3333
<li class="prev disabled"><span><i class="fa fw fa-arrow-left"></i> {{ 'paginator.previous'|trans }}</span></li>
3434
{% endif %}
@@ -37,12 +37,12 @@
3737
{% if i == paginator.currentPage %}
3838
<li class="active"><span>{{ i }} <span class="sr-only">{{ 'paginator.current'|trans }}</span></span></li>
3939
{% else %}
40-
<li><a href="{{ path('blog_index_paginated', {page: i}) }}">{{ i }}</a></li>
40+
<li><a href="{{ path('blog_index_paginated', {page: i, tag: tagName}) }}">{{ i }}</a></li>
4141
{% endif %}
4242
{% endfor %}
4343

4444
{% if paginator.hasNextPage %}
45-
<li class="next"><a href="{{ path('blog_index_paginated', {page: paginator.nextPage}) }}" rel="next">{{ 'paginator.next'|trans }} <i class="fa fw fa-arrow-right"></i></a></li>
45+
<li class="next"><a href="{{ path('blog_index_paginated', {page: paginator.nextPage, tag: tagName}) }}" rel="next">{{ 'paginator.next'|trans }} <i class="fa fw fa-arrow-right"></i></a></li>
4646
{% else %}
4747
<li class="next disabled"><span>{{ 'paginator.next'|trans }} <i class="fa fw fa-arrow-right"></i></span></li>
4848
{% endif %}

0 commit comments

Comments
 (0)