templates/partial/pagination.html.twig line 1

Open in your IDE?
  1. {% if pageCount > 1 %}
  2.     <nav>
  3.         {% set classAlign = (align is not defined) ? '' : align=='center' ? ' justify-content-center' : (align=='right' ? ' justify-content-end' : '') %}
  4.         {% set classSize = (size is not defined) ? '' : size=='large' ? ' pagination-lg' : (size=='small' ? ' pagination-sm' : '') %}
  5.         <ul class="pagination{{ classAlign }}{{ classSize }} text-center">
  6.             {% if previous is defined %}
  7.                 <li class="page-item">
  8.                     <a class="page-link" rel="prev" href="{{ path(route, query|merge({(pageParameterName): (previous ==1 ? null : previous)})) }}">&laquo;&nbsp;{{ 'label_previous'|trans({}, 'KnpPaginatorBundle') }}</a>
  9.                 </li>
  10.             {% else %}
  11.                 <li class="page-item disabled">
  12.                     <span class="page-link">&laquo;&nbsp;{{ 'label_previous'|trans({}, 'KnpPaginatorBundle') }}</span>
  13.                 </li>
  14.             {% endif %}
  15.             {% if startPage > 1 %}
  16.                 <li class="page-item">
  17.                     <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): 1})) }}">1</a>
  18.                 </li>
  19.                 {% if startPage == 3 %}
  20.                     <li class="page-item">
  21.                         <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): 2})) }}">2</a>
  22.                     </li>
  23.                 {% elseif startPage != 2 %}
  24.                     <li class="page-item disabled">
  25.                         <span class="page-link">&hellip;</span>
  26.                     </li>
  27.                 {% endif %}
  28.             {% endif %}
  29.             {% for page in pagesInRange %}
  30.                 {% if page != current %}
  31.                     <li class="page-item">
  32.                         <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): (page ==1 ? null : page)})) }}">{{ page }}</a>
  33.                     </li>
  34.                 {% else %}
  35.                     <li class="page-item active">
  36.                         <span class="page-link">{{ page }}</span>
  37.                     </li>
  38.                 {% endif %}
  39.             {% endfor %}
  40.             {% if pageCount > endPage %}
  41.                 {% if pageCount > (endPage + 1) %}
  42.                     {% if pageCount > (endPage + 2) %}
  43.                         <li class="page-item disabled">
  44.                             <span class="page-link">&hellip;</span>
  45.                         </li>
  46.                     {% else %}
  47.                         <li class="page-item">
  48.                             <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): (pageCount - 1)})) }}">{{ pageCount -1 }}</a>
  49.                         </li>
  50.                     {% endif %}
  51.                 {% endif %}
  52.                 <li class="page-item">
  53.                     <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): pageCount})) }}">{{ pageCount }}</a>
  54.                 </li>
  55.             {% endif %}
  56.             {% if next is defined %}
  57.                 <li class="page-item">
  58.                     <a class="page-link" rel="next" href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ 'label_next'|trans({}, 'KnpPaginatorBundle') }}&nbsp;&raquo;</a>
  59.                 </li>
  60.             {% else %}
  61.                 <li  class="page-item disabled">
  62.                     <span class="page-link">{{ 'label_next'|trans({}, 'KnpPaginatorBundle') }}&nbsp;&raquo;</span>
  63.                 </li>
  64.             {% endif %}
  65.         </ul>
  66.     </nav>
  67.     {% set doublePaginationCount =  pageCount // 10 %}
  68.     {% if doublePaginationCount >= 2 %}
  69.         <nav class="doublePagination">
  70.             <ul>
  71.                 {% for i in 1..10 %}
  72.                     {% if doublePaginationCount >= 1 and i <= doublePaginationCount %}
  73.                         {% set pageNumber = i ~ '0' %}
  74.                         <li>
  75.                             <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): pageNumber })) }}">{{ pageNumber }}</a>
  76.                         </li>
  77.                     {% endif %}
  78.                 {% endfor %}
  79.             </ul>
  80.         </nav>
  81.     {% endif %}
  82. {% endif %}