custom/plugins/DecomTheme/src/Resources/views/storefront/component/pagination.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/pagination.html.twig' %}
  2. {% block component_pagination_nav %}
  3.     {% set currentPage = ((criteria.offset + 1) / criteria.limit )|round(0, 'ceil') %}
  4.     {% set totalPages = (entities.total / 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_prev %}
  10.                     <li class="page-item page-prev{% if currentPage == 1 %} disabled{% endif %}">
  11.                         {% block component_pagination_prev_input %}
  12.                             <input type="radio"
  13.                                    {% if currentPage == 1 %}disabled="disabled"{% endif %}
  14.                                    name="p"
  15.                                    id="p-prev"
  16.                                    value="{{ currentPage - 1 }}"
  17.                                    class="d-none"
  18.                                    title="pagination">
  19.                         {% endblock %}
  20.                         {% block component_pagination_prev_label %}
  21.                             <label class="page-link" for="p-prev">
  22.                                 {% block component_pagination_prev_link %}
  23.                                     {% block component_pagination_prev_icon %}
  24.                                         {% sw_icon 'arrow-medium-left' style {'size': 'fluid', 'pack': 'solid'} %}
  25.                                     {% endblock %}
  26.                                 {% endblock %}
  27.                             </label>
  28.                         {% endblock %}
  29.                     </li>
  30.                 {% endblock %}
  31.                 {% block component_pagination_loop %}
  32.                     {% set start = currentPage - 2 %}
  33.                     {% if start <= 0 %}
  34.                         {% set start = currentPage - 1 %}
  35.                         {% if start <= 0 %}
  36.                             {% set start = currentPage %}
  37.                         {% endif %}
  38.                     {% endif %}
  39.                     {% set end = start + 4 %}
  40.                     {% if end > totalPages %}
  41.                         {% set end = totalPages %}
  42.                     {% endif %}
  43.                     {% for page in start..end %}
  44.                         {% set isActive = (currentPage == page) %}
  45.                         {% block component_pagination_item %}
  46.                             <li class="page-item{% if isActive %} active{% endif %}">
  47.                                 {% block component_pagination_item_input %}
  48.                                     <input type="radio"
  49.                                            name="p"
  50.                                            id="p{{ page }}"
  51.                                            value="{{ page }}"
  52.                                            class="d-none"
  53.                                            title="pagination"
  54.                                            {% if isActive %}checked="checked"{% endif %}>
  55.                                 {% endblock %}
  56.                                 {% block component_pagination_item_label %}
  57.                                     <label class="page-link"
  58.                                            for="p{{ page }}">
  59.                                         {% block component_pagination_item_link %}
  60.                                             {% block component_pagination_item_text %}
  61.                                                 {{ page }}
  62.                                             {% endblock %}
  63.                                         {% endblock %}
  64.                                     </label>
  65.                                 {% endblock %}
  66.                             </li>
  67.                         {% endblock %}
  68.                     {% endfor %}
  69.                 {% endblock %}
  70.                 {% block component_pagination_next %}
  71.                     <li class="page-item page-next{% if currentPage == totalPages %} disabled{% endif %}">
  72.                         {% block component_pagination_next_input %}
  73.                             <input type="radio"
  74.                                    {% if currentPage == totalPages %}disabled="disabled"{% endif %}
  75.                                    name="p"
  76.                                    id="p-next"
  77.                                    value="{{ currentPage + 1 }}"
  78.                                    class="d-none"
  79.                                    title="pagination">
  80.                         {% endblock %}
  81.                         {% block component_pagination_next_label %}
  82.                             <label class="page-link" for="p-next">
  83.                                 {% block component_pagination_next_link %}
  84.                                     {% block component_pagination_next_icon %}
  85.                                         {% sw_icon 'arrow-medium-right' style { 'size': 'fluid', 'pack': 'solid'} %}
  86.                                     {% endblock %}
  87.                                 {% endblock %}
  88.                             </label>
  89.                         {% endblock %}
  90.                     </li>
  91.                 {% endblock %}
  92.             </ul>
  93.         {% endblock %}
  94.         </nav>
  95.     {% endif %}
  96. {% endblock %}