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