{% if (paginationPosition == 'top' and pagination.currentPage > 1) or (paginationPosition == 'bottom' and pagination.totalPages > pagination.currentPage) %}
<div class="pagination">
{% if paginationPosition == 'top' %}
{% if pagination.currentPage > startPage %}
{% set page = (startPage - 1) %}
{% else %}
{% set page = (pagination.currentPage - 1) %}
{% endif %}
{% set buttonText = 'pagination_more_before_text'|trans %}
{% else %}
{% if pagination.currentPage < startPage %}
{% set page = (startPage + 1) %}
{% else %}
{% set page = (pagination.currentPage + 1) %}
{% endif %}
{% set buttonText = 'pagination_more_text'|trans %}
{% endif %}
{% if( dataPath is defined) %}
{%if current_sorting is defined and current_sorting is not null %}
{% set path = path(dataPath, {'page': page, 'q': searchText, 'startPage': startPage, 'sort[field]':current_sorting.field, 'sort[order]': current_sorting.order}) %}
{%else%}
{% set path = path(dataPath, {'page': page, 'q': searchText, 'startPage': startPage}) %}
{%endif%}
{% else %}
{%if current_sorting is defined and current_sorting is not null %}
{% set path = path('app_catalog_get_more_products', {'categoryId': category.id, 'page': page, 'startPage': startPage, 'sort[field]':current_sorting.field, 'sort[order]': current_sorting.order}) %}
{%else%}
{% set path = path('app_catalog_get_more_products', {'categoryId': category.id, 'page': page, 'startPage': startPage}) %}
{%endif%}
{% endif %}
{% include('components/atoms/text-link/text-link.html.twig') with {
'href': '?page=' ~ page,
'text': buttonText,
'class': 'button button--multitool button--width-auto js-pagination',
'attributes': {
'data-pagination-ajax-url': path,
'data-product-grid-inner': '.product-grid',
'data-pagination-inner-top': '.listing__pagination--top',
'data-pagination-inner-bottom': '.listing__pagination--bottom',
'data-pagination-position': paginationPosition
}
} %}
{% if paginationPosition == 'bottom' %}
<p class="pagination__count">{{ 'pagination_product_counter'|trans({'%productsFrom%': (pagination.currentPage * pagination.itemsPerPage), '%productsTo%': pagination.totalItems}) }}</p>
{% endif %}
</div>
{% endif %}