src/Elements/Bundle/DemiFrontendBundle/Resources/views/Includes/paging.html.twig line 1

Open in your IDE?
  1. {#
  2. this is not the twig version of the php paging template in this folder
  3. this is a generic paging template
  4. #}
  5. {% set leftIcon = leftIcon|default('icon-arrow-left page-link__arrow') %}
  6. {% set rightIcon = rightIcon|default('icon-arrow-right page-link__arrow') %}
  7. {% set hideCount = hideCount|default(false) %}
  8. {% set addClassArray = addClassArray|default([]) %}
  9. {% if hideCount %}
  10.     {% set addClassArray = addClassArray|merge(['no-paging--count']) %}
  11. {% endif %}
  12. {% set path = app.request.get("baseUrl") %}
  13. {% do app.request.query.remove("baseUrl") %}
  14. {% do app.request.query.remove("page") %}
  15. {% do app.request.query.remove("ajax") %}
  16. {% set queryString = "" %}
  17. {% if app.request.query is not empty %}
  18.     {% set queryString = "&" ~ app.request.query.all | url_encode %}
  19. {% endif %}
  20. {% if addClass|default('') is not empty %}
  21.     {% set addClassArray = addClassArray|merge([addClass]) %}
  22. {% endif %}
  23. {% set totalItemCount = demi_hasKnpPaginator() ? totalCount|default(0) : totalItemCount|default(0) %}
  24. <div class="{{ pagingClass|default('') }}">
  25.     <div class="row align-items-center {{ addClassArray|join('') }}">
  26.         {% if not hideCount %}
  27.             <div class="col-md-4 has-paging--count">
  28.                 <div class="row row--gutter-with-10">
  29.                     <div class="col-md-auto text-center text-md-left text-nowrap">
  30.                         {{ totalItemCount }} {{ totalItemCount == 1 ? resultTk|default('demi.infrastructure.paging.result')|trans : resultsTk|default('demi.infrastructure.paging.results')|trans }}
  31.                     </div>
  32.                 </div>
  33.             </div>
  34.         {% endif %}
  35.         {% if pageCount > 1 %}
  36.             <div class="col-md-8 has-paging--list">
  37.                 <ul class="pagination justify-content-center justify-content-md-end js-filter-form-paging">
  38.                     {% if previous|default('') %}
  39.                         {% do pimcore_placeholder('headPrev').set('<link rel="prev" href="' ~ path ~ "?page=" ~ previous ~ queryString ~ '">') %}
  40.                         <li class="li-has-arrow page-item">
  41.                             <a class="page-link {{ pageLinkClass|default('') }}" href="{{ path ~ "?page=" ~ previous ~ queryString  }}"
  42.                                data-page="{{ previous }}" rel="prev">
  43.                                 <span class="icon icon-in-text {{ leftIcon }}"></span>
  44.                             </a>
  45.                         </li>
  46.                     {% else %}
  47.                         <li class="disabled li-has-arrow page-item">
  48.                             <a class="page-link" href="#">
  49.                                 <span class="icon icon-in-text {{ leftIcon }}"></span>
  50.                             </a>
  51.                         </li>
  52.                     {% endif %}
  53.                     {% if showFirstLast|default(false) %}
  54.                         {% if firstPageInRange != first %}
  55.                             <li class="page-item">
  56.                                 <a class="page-link {{ pageLinkClass|default('') }}"
  57.                                    href="{{ path ~ "?page=" ~ first }}" data-page="{{ first }}">
  58.                                     {{ first }}
  59.                                 </a>
  60.                             </li>
  61.                         {% endif %}
  62.                         {% if firstPageInRange > first +1 and firstPageInRange < first+3 %}
  63.                             <li class="page-item">
  64.                                 <a class="page-link {{ pageLinkClass|default('') }}"
  65.                                    href="{{ path ~ "?page=" ~ first+1 ~ queryString }}" data-page="{{ first+1 }}">
  66.                                     {{ first+1 }}
  67.                                 </a>
  68.                             </li>
  69.                         {% endif %}
  70.                         {% if firstPageInRange > first +2 %}
  71.                             <li class="page-item">
  72.                                 <a class="page-link" href="#">...</a>
  73.                             </li>
  74.                         {% endif %}
  75.                     {% endif %}
  76.                     {% for page in pagesInRange %}
  77.                         {% if page != current %}
  78.                             <li class="page-item">
  79.                                 <a class="page-link {{ pageLinkClass|default('') }}" href="{{ path ~ "?page=" ~ page ~ queryString }}"
  80.                                    data-page="{{ page }}">
  81.                                     {{ page }}
  82.                                 </a>
  83.                             </li>
  84.                         {% else %}
  85.                             <li class="active page-item">
  86.                                 <a class="page-link {{ pageLinkClass|default('') }}" href="" data-page="{{ page }}">
  87.                                     {{ page }}
  88.                                     <span class="sr-only">({{ 'sr.page.current'|trans }})</span>
  89.                                 </a>
  90.                             </li>
  91.                         {% endif %}
  92.                     {% endfor %}
  93.                     {% if showFirstLast|default(false) %}
  94.                         {% if lastPageInRange < last-2 %}
  95.                             <li class="disabled page-item">
  96.                                 <a class="page-link {{ pageLinkClass|default('') }}" href="#">...</a>
  97.                             </li>
  98.                         {% endif %}
  99.                         {% if lastPageInRange < last-1 and lastPageInRange > last-3 %}
  100.                             <li class="page-item">
  101.                                 <a class="page-link {{ pageLinkClass|default('') }}"
  102.                                    href="{{ path ~ "?page=" ~ last-1 ~ queryString }}" data-page="{{ last-1 }}">
  103.                                     {{ last-1 }}
  104.                                 </a>
  105.                             </li>
  106.                         {% endif %}
  107.                         {% if lastPageInRange != last %}
  108.                             <li class="page-item">
  109.                                 <a class="page-link {{ pageLinkClass|default('') }}" href="{{ path ~ "?page=" ~ last ~ queryString  }}"
  110.                                    data-page="{{ last }}">
  111.                                     {{ last }}
  112.                                 </a>
  113.                             </li>
  114.                         {% endif %}
  115.                     {% endif %}
  116.                     {% if next|default(null) %}
  117.                         {% do pimcore_placeholder('headNext').set('<link rel="next" href="' ~ path ~ "?page=" ~ next ~ queryString ~ '">') %}
  118.                         <li class="page-item">
  119.                             <a class="page-link {{ pageLinkClass|default('') }}" href="{{ path ~ "?page=" ~ next ~ queryString }}"
  120.                                data-page="{{ next }}">
  121.                                 <span class="icon icon-in-text {{ rightIcon }}"></span>
  122.                             </a>
  123.                         </li>
  124.                     {% else %}
  125.                         <li class="disabled li-has-arrow page-item">
  126.                             <a class="page-link" href="#">
  127.                                 <span class="icon icon-in-text {{ rightIcon }}"></span>
  128.                             </a>
  129.                         </li>
  130.                     {% endif %}
  131.                 </ul>
  132.             </div>
  133.         {% endif %}
  134.     </div>
  135. </div>