Last active
May 25, 2017 11:13
-
-
Save ajaxray/dcc781e72f0cdf763beb to your computer and use it in GitHub Desktop.
Bootstrap 3 style pagination template for Symfony KnpPaginatorBundle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From http://stackoverflow.com/a/23035644/228648 | |
# Update pagination config in config.yml as: | |
knp_paginator: | |
template: | |
pagination: AcmeBundle:Common:paginator-bootstrap.html.twig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if pageCount > 1 %} | |
<ul class="pagination"> | |
{% if first is defined and current != first %} | |
<li class="first"><a href="{{ path(route, query|merge({(pageParameterName): first})) }}"><<</a></li> | |
{% endif %} | |
{% if previous is defined %} | |
<li class="previous"><a class="hidden-xs" href="{{ path(route, query|merge({(pageParameterName): previous})) }}"><</a></li> | |
{% endif %} | |
{% for page in pagesInRange %} | |
{% if page != current %} | |
<li class="page"><a href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a></li> | |
{% else %} | |
<li class="current active"><a>{{ page }} <span class="sr-only">(current)</span></a></li> | |
{% endif %} | |
{% endfor %} | |
{% if next is defined %} | |
<li class="next"><a class="hidden-xs" href="{{ path(route, query|merge({(pageParameterName): next})) }}">></a></li> | |
{% endif %} | |
{% if last is defined and current != last %} | |
<li class="last"><a href="{{ path(route, query|merge({(pageParameterName): last})) }}">>></a></li> | |
{% endif %} | |
</ul> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment