templates/component/pagination.html.twig line 1

Open in your IDE?
  1. {# Tablet / Desktop #}
  2. {% set pages = pagination.paginationData %}
  3. <ul class="hidden gap-2 md:flex">
  4.   {% include 'component/pagination_page.html.twig' with {
  5.     page: pages.first ?? null,
  6.     label: 'pagination.first'|trans,
  7.     disabled: pages.first is not defined
  8.   } %}
  9.   {% include 'component/pagination_page.html.twig' with {
  10.     page: pages.previous ?? null,
  11.     label: 'pagination.previous'|trans,
  12.     disabled: pages.previous is not defined
  13.   } %}
  14.   {% for page in pages.pagesInRange %}
  15.     {% include 'component/pagination_page.html.twig' with {
  16.       page: page,
  17.       label: page,
  18.       current: page == pages.current
  19.     } %}
  20.   {% endfor %}
  21.   {% include 'component/pagination_page.html.twig' with {
  22.     page: pages.next ?? null,
  23.     label: 'pagination.next'|trans,
  24.     disabled: pages.next is not defined
  25.   } %}
  26.   {% include 'component/pagination_page.html.twig' with {
  27.     page: pages.last ?? null,
  28.     label: 'pagination.last'|trans,
  29.     disabled: pages.last is not defined
  30.   } %}
  31. </ul>
  32. {# Mobile #}
  33. <form class="flex justify-end w-full" action="" method="get">
  34.   <script>
  35.     var target = new URL('{{ url(app.request.get('_route'), app.request.query.all) | raw }}');
  36.     function onSelectChange(event) {
  37.       event.preventDefault();
  38.       target.searchParams.set('page', event.target.value);
  39.       window.location.href = target;
  40.     }
  41.   </script>
  42.   <select onchange="onSelectChange(event)"
  43.     class="w-full text-center md:hidden form-control">
  44.     {% for page in 1..pages.pageCount %}
  45.       <option value="{{ page }}" {{ pages.current == page ? 'selected' }}>
  46.         {{ page }}
  47.       </option>
  48.     {% endfor %}
  49.   </select>
  50. </form>