vendor/shopware/storefront/Resources/views/storefront/component/pagination.html.twig line 1

Open in your IDE?
  1. {% block component_pagination_nav %}
  2.     {% set currentPage = ((criteria.offset + 1) / criteria.limit)|round(0, 'ceil') %}
  3.     {% set totalEntities = total ? total : entities.total %}
  4.     {% set totalPages = (totalEntities / criteria.limit)|round(0, 'ceil') %}
  5.     {% if totalPages > 1 %}
  6.         <nav aria-label="pagination" class="pagination-nav">
  7.             {% block component_pagination %}
  8.             <ul class="pagination">
  9.                 {% block component_pagination_first %}
  10.                     <li class="page-item page-first{% if currentPage == 1 %} disabled{% endif %}">
  11.                         {% block component_pagination_first_input %}
  12.                             <input type="radio"
  13.                                    {% if currentPage == 1 %}disabled="disabled"{% endif %}
  14.                                    name="p"
  15.                                    id="p-first"
  16.                                    value="1"
  17.                                    class="d-none"
  18.                                    title="pagination">
  19.                         {% endblock %}
  20.                         {% block component_pagination_first_label %}
  21.                             <label class="page-link" for="p-first">
  22.                                 {% block component_pagination_first_link %}
  23.                                     {% sw_icon 'arrow-medium-double-left' style { 'size': 'fluid', 'pack': 'solid'} %}
  24.                                 {% endblock %}
  25.                             </label>
  26.                         {% endblock %}
  27.                     </li>
  28.                 {% endblock %}
  29.                 {% block component_pagination_prev %}
  30.                     <li class="page-item page-prev{% if currentPage == 1 %} disabled{% endif %}">
  31.                         {% block component_pagination_prev_input %}
  32.                             <input type="radio"
  33.                                    {% if currentPage == 1 %}disabled="disabled"{% endif %}
  34.                                    name="p"
  35.                                    id="p-prev"
  36.                                    value="{{ currentPage - 1 }}"
  37.                                    class="d-none"
  38.                                    title="pagination">
  39.                         {% endblock %}
  40.                         {% block component_pagination_prev_label %}
  41.                             <label class="page-link" for="p-prev">
  42.                                 {% block component_pagination_prev_link %}
  43.                                     {% block component_pagination_prev_icon %}
  44.                                         {% sw_icon 'arrow-medium-left' style {'size': 'fluid', 'pack': 'solid'} %}
  45.                                     {% endblock %}
  46.                                 {% endblock %}
  47.                             </label>
  48.                         {% endblock %}
  49.                     </li>
  50.                 {% endblock %}
  51.                 {% block component_pagination_loop %}
  52.                     {% set start = currentPage - 2 %}
  53.                     {% if start <= 0 %}
  54.                         {% set start = currentPage - 1 %}
  55.                         {% if start <= 0 %}
  56.                             {% set start = currentPage %}
  57.                         {% endif %}
  58.                     {% endif %}
  59.                     {% set end = start + 4 %}
  60.                     {% if end > totalPages %}
  61.                         {% set end = totalPages %}
  62.                     {% endif %}
  63.                     {% for page in start..end %}
  64.                         {% set isActive = (currentPage == page) %}
  65.                         {% block component_pagination_item %}
  66.                             <li class="page-item{% if isActive %} active{% endif %}">
  67.                                 {% block component_pagination_item_input %}
  68.                                     <input type="radio"
  69.                                            name="p"
  70.                                            id="p{{ page }}"
  71.                                            value="{{ page }}"
  72.                                            class="d-none"
  73.                                            title="pagination"
  74.                                            {% if isActive %}checked="checked"{% endif %}>
  75.                                 {% endblock %}
  76.                                 {% block component_pagination_item_label %}
  77.                                     <label class="page-link"
  78.                                            for="p{{ page }}">
  79.                                         {% block component_pagination_item_link %}
  80.                                             {% block component_pagination_item_text %}
  81.                                                 {{ page }}
  82.                                             {% endblock %}
  83.                                         {% endblock %}
  84.                                     </label>
  85.                                 {% endblock %}
  86.                             </li>
  87.                         {% endblock %}
  88.                     {% endfor %}
  89.                 {% endblock %}
  90.                 {% block component_pagination_next %}
  91.                     <li class="page-item page-next{% if currentPage == totalPages %} disabled{% endif %}">
  92.                         {% block component_pagination_next_input %}
  93.                             <input type="radio"
  94.                                    {% if currentPage == totalPages %}disabled="disabled"{% endif %}
  95.                                    name="p"
  96.                                    id="p-next"
  97.                                    value="{{ currentPage + 1 }}"
  98.                                    class="d-none"
  99.                                    title="pagination">
  100.                         {% endblock %}
  101.                         {% block component_pagination_next_label %}
  102.                             <label class="page-link" for="p-next">
  103.                                 {% block component_pagination_next_link %}
  104.                                     {% block component_pagination_next_icon %}
  105.                                         {% sw_icon 'arrow-medium-right' style { 'size': 'fluid', 'pack': 'solid'} %}
  106.                                     {% endblock %}
  107.                                 {% endblock %}
  108.                             </label>
  109.                         {% endblock %}
  110.                     </li>
  111.                 {% endblock %}
  112.                 {% block component_pagination_last %}
  113.                     <li class="page-item page-last{% if currentPage == totalPages %} disabled{% endif %}">
  114.                         {% block component_pagination_last_input %}
  115.                             <input type="radio"
  116.                                    {% if currentPage == totalPages %}disabled="disabled"{% endif %}
  117.                                    name="p"
  118.                                    id="p-last"
  119.                                    value="{{ totalPages }}"
  120.                                    class="d-none"
  121.                                    title="pagination">
  122.                         {% endblock %}
  123.                         {% block component_pagination_last_label %}
  124.                             <label class="page-link" for="p-last">
  125.                                 {% block component_pagination_last_link %}
  126.                                     {% block component_pagination_last_icon %}
  127.                                         {% sw_icon 'arrow-medium-double-right' style {
  128.                                             'size': 'fluid',
  129.                                             'pack': 'solid'
  130.                                         } %}
  131.                                     {% endblock %}
  132.                                 {% endblock %}
  133.                             </label>
  134.                         {% endblock %}
  135.                     </li>
  136.                 {% endblock %}
  137.             </ul>
  138.         {% endblock %}
  139.         </nav>
  140.     {% endif %}
  141. {% endblock %}