templates/pagination.html.twig line 1

Open in your IDE?
  1. {#
  2. /**
  3.  * @file
  4.  * Bootstrap 5 Pagination with Lucide Icons
  5.  *
  6.  * View that can be used with the KnpPaginator bundle
  7.  * https://getbootstrap.com/docs/5.3/components/pagination/
  8.  *
  9.  */
  10. #}
  11. {% if pageCount > 1 %}
  12.     <nav aria-label="Page navigation">
  13.         {% set classAlign = (align is not defined) ? '' : align=='center' ? ' justify-content-center' : (align=='right' ? ' justify-content-end' : '') %}
  14.         {% set classSize = (size is not defined) ? ' pagination-sm' : size=='large' ? ' pagination-lg' : (size=='small' ? ' pagination-sm' : '') %}
  15.         <ul class="pagination{{ classAlign }}{{ classSize }} mb-0">
  16.             {# First Page #}
  17.             {% if first is defined and current > 2 %}
  18.                 <li class="page-item">
  19.                     <a href="{{ path(route, query|merge({(pageParameterName): first})) }}" class="page-link" aria-label="First" data-bs-toggle="tooltip" title="First page">
  20.                         <i data-lucide="chevrons-left" style="width: 14px; height: 14px;"></i>
  21.                     </a>
  22.                 </li>
  23.             {% endif %}
  24.             {# Previous Page #}
  25.             {% if previous is defined %}
  26.                 <li class="page-item">
  27.                     <a href="{{ path(route, query|merge({(pageParameterName): previous})) }}" class="page-link" aria-label="Previous">
  28.                         <i data-lucide="chevron-left" style="width: 14px; height: 14px;"></i>
  29.                     </a>
  30.                 </li>
  31.             {% else %}
  32.                 <li class="page-item disabled">
  33.                     <span class="page-link" aria-label="Previous">
  34.                         <i data-lucide="chevron-left" style="width: 14px; height: 14px;"></i>
  35.                     </span>
  36.                 </li>
  37.             {% endif %}
  38.             {# Page Numbers #}
  39.             {% if startPage > 1 %}
  40.                 <li class="page-item">
  41.                     <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): 1})) }}">1</a>
  42.                 </li>
  43.                 {% if startPage > 2 %}
  44.                     <li class="page-item disabled">
  45.                         <span class="page-link">…</span>
  46.                     </li>
  47.                 {% endif %}
  48.             {% endif %}
  49.             {% for page in pagesInRange %}
  50.                 {% if page != current %}
  51.                     <li class="page-item">
  52.                         <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a>
  53.                     </li>
  54.                 {% else %}
  55.                     <li class="page-item active" aria-current="page">
  56.                         <span class="page-link">{{ page }}</span>
  57.                     </li>
  58.                 {% endif %}
  59.             {% endfor %}
  60.             {% if endPage < pageCount %}
  61.                 {% if endPage < pageCount - 1 %}
  62.                     <li class="page-item disabled">
  63.                         <span class="page-link">…</span>
  64.                     </li>
  65.                 {% endif %}
  66.                 <li class="page-item">
  67.                     <a class="page-link" href="{{ path(route, query|merge({(pageParameterName): pageCount})) }}">{{ pageCount }}</a>
  68.                 </li>
  69.             {% endif %}
  70.             {# Next Page #}
  71.             {% if next is defined %}
  72.                 <li class="page-item">
  73.                     <a class="page-link" rel="next" href="{{ path(route, query|merge({(pageParameterName): next})) }}" aria-label="Next">
  74.                         <i data-lucide="chevron-right" style="width: 14px; height: 14px;"></i>
  75.                     </a>
  76.                 </li>
  77.             {% else %}
  78.                 <li class="page-item disabled">
  79.                     <span class="page-link" aria-label="Next">
  80.                         <i data-lucide="chevron-right" style="width: 14px; height: 14px;"></i>
  81.                     </span>
  82.                 </li>
  83.             {% endif %}
  84.             {# Last Page #}
  85.             {% if last is defined and current < pageCount - 1 %}
  86.                 <li class="page-item">
  87.                     <a href="{{ path(route, query|merge({(pageParameterName): last})) }}" class="page-link" aria-label="Last" data-bs-toggle="tooltip" title="Last page">
  88.                         <i data-lucide="chevrons-right" style="width: 14px; height: 14px;"></i>
  89.                     </a>
  90.                 </li>
  91.             {% endif %}
  92.         </ul>
  93.     </nav>
  94.     {# Re-initialize Lucide icons for pagination #}
  95.     <script>
  96.         if (typeof lucide !== 'undefined') {
  97.             lucide.createIcons();
  98.         }
  99.     </script>
  100. {% endif %}