templates/bundles/knp-paginator-bundle/pagination.html.twig line 1

Open in your IDE?
  1. {#
  2. /**
  3.  * @file
  4.  * Twitter Bootstrap v4-beta.2 Sliding pagination control implementation.
  5.  *
  6.  * View that can be used with the pagination module
  7.  * from the Twitter Bootstrap CSS Toolkit
  8.  * https://getbootstrap.com/docs/4.0/components/pagination/
  9.  *
  10.  */
  11. #}
  12. {% if pageCount > 1 %}
  13.     <nav>
  14.         {% set classAlign = (align is not defined) ? '' : align=='center' ? ' justify-content-center' : (align=='right' ? ' justify-content-end' : '') %}
  15.         {% set classSize = (size is not defined) ? '' : size=='large' ? ' pagination-lg' : (size=='small' ? ' pagination-sm' : '') %}
  16.         <ul class="pagination{{ classAlign }}{{ classSize }}" style="width: fit-content; margin-left: auto; margin-right: auto;">
  17.             {% if previous is defined %}
  18.                 <li class="page-item">
  19.                     <a class="page-link" rel="prev" href="{{ path(route, query|merge({(pageParameterName): previous})) }}">&laquo;&nbsp;{{ 'label_previous'|trans({}) }}</a>
  20.                 </li>
  21.             {% endif %}
  22.             {% if startPage > 1 %}
  23.                 <li class="page-item">
  24.                     <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): 1})) }}">1</a>
  25.                 </li>
  26.                 {% if startPage == 3 %}
  27.                     <li class="page-item">
  28.                         <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): 2})) }}">2</a>
  29.                     </li>
  30.                 {% elseif startPage != 2 %}
  31.                     <li class="page-item disabled">
  32.                         <span class="page-link">&hellip;</span>
  33.                     </li>
  34.                 {% endif %}
  35.             {% endif %}
  36.             {% for page in pagesInRange %}
  37.                 {% if page != current %}
  38.                     <li class="page-item">
  39.                         <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a>
  40.                     </li>
  41.                 {% else %}
  42.                     <li class="page-item active">
  43.                         <span class="page-link">{{ page }}</span>
  44.                     </li>
  45.                 {% endif %}
  46.             {% endfor %}
  47.             {% if pageCount > endPage %}
  48.                 {% if pageCount > (endPage + 1) %}
  49.                     {% if pageCount > (endPage + 2) %}
  50.                         <li class="page-item disabled">
  51.                             <span class="page-link">&hellip;</span>
  52.                         </li>
  53.                     {% else %}
  54.                         <li class="page-item">
  55.                             <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): (pageCount - 1)})) }}">{{ pageCount -1 }}</a>
  56.                         </li>
  57.                     {% endif %}
  58.                 {% endif %}
  59.                 <li class="page-item">
  60.                     <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): pageCount})) }}">{{ pageCount }}</a>
  61.                 </li>
  62.             {% endif %}
  63.             {% if next is defined %}
  64.                 <li class="page-item">
  65.                     <a class="page-link page-next" rel="next" href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ 'label_next'|trans({}) }}&nbsp;&raquo;</a>
  66.                 </li>
  67.             {% endif %}
  68.         </ul>
  69.     </nav>
  70. {% endif %}