|
|
- {% spaceless %}
- {% if lastPage > 1 %}
-
- {# the number of first and last pages to be displayed #}
- {% set extremePagesLimit = 3 %}
-
- {# the number of pages that are displayed around the active page #}
- {% set nearbyPagesLimit = 2 %}
-
- {% if currentFilters is not defined %}{% set currentFilters = {} %}{% endif %}
- {% if paginationPath is not defined %}{% set paginationPath = app.request.attributes.get('_route') %}{% endif %}
- {% if showAlwaysFirstAndLast is not defined %}{% set showAlwaysFirstAndLast = true %}{% endif %}
-
- <!-- Pagination -->
- <ul class="pagination justify-content-center mb-4">
- {% if currentPage > 1 %}
- <li class="page-item">
- <a class="page-link" href="page={{ currentPage-1 }}">← Previous page</a>
- </li>
-
- {% for i in range(1, extremePagesLimit) if ( i < currentPage - nearbyPagesLimit ) %}
- <li class="page-item">
- <a class="page-link" href="page={{ i }}">{{ i }}</a>
- </li>
- {% endfor %}
-
- {% if extremePagesLimit + 1 < currentPage - nearbyPagesLimit %}
- <li class="page-item disabled">
- <a class="page-link">…</a>
- </li>
- {% endif %}
-
- {% for i in range(currentPage-nearbyPagesLimit, currentPage-1) if ( i > 0 ) %}
- <li class="page-item">
- <a class="page-link" href="page={{ i }}">{{ i }}</a>
- </li>
- {% endfor %}
- {% elseif showAlwaysFirstAndLast %}
- <li class="page-item disabled">
- <a class="page-link">← Previous page</a>
- </li>
- {% endif %}
-
- <li class="page-item disabled">
- <a class="page-link">{{currentPage }}</a>
- </li>
-
- {% if currentPage < lastPage %}
- {% for i in range(currentPage+1, currentPage + nearbyPagesLimit) if ( i <= lastPage ) %}
- <li class="page-item">
- <a class="page-link" href="page={{ i }}">{{ i }}</a>
- </li>
- {% endfor %}
-
- {% if (lastPage - extremePagesLimit) > (currentPage + nearbyPagesLimit) %}
- <li class="page-item disabled">
- <a class="page-link">…</a>
- </li>
- {% endif %}
-
- {% for i in range(lastPage - extremePagesLimit+1, lastPage) if ( i > currentPage + nearbyPagesLimit ) %}
- <li class="page-item">
- <a class="page-link" href="page={{ i }}">{{ i }}</a>
- </li>
- {% endfor %}
- <li class="page-item">
- <a class="page-link" href="page={{ currentPage+1 }}">Next Page →</a>
- </li>
- {% elseif showAlwaysFirstAndLast %}
- <li class="page-item disabled">
- <a class="page-link">Next Page →</a>
- </li>
- {% endif %}
- </ul>
- {% endif %}
- {% endspaceless %}
|