{% set config = { sorting: current } %}
{% set showSorting = (slot.config.showSorting.value is defined) ? slot.config.showSorting.value : true %}
{% if showSorting and sortings|length > 1 %}
<div class="sorting custom-select-wrap" data-listing-sorting="true" data-listing-sorting-options='{{ config|json_encode }}'>
<label>{{ "chespackTheme.category.sortBy"|trans|sw_sanitize }}</label>
<select class="sorting custom-select" aria-label="{{ 'general.sortingLabel'|trans|striptags }}">
{% for sorting in sortings %}
{% set key = sorting.key %}
<option value="{{ key }}"{% if key == current %} selected{% endif %}>{{ sorting.translated.label|sw_sanitize }}</option>
{% endfor %}
</select>
</div>
{% endif %}
{# Add products counter #}
{% if controllerName == 'Search' %}
{% set listing = page.listing %}
{% else %}
{% set listing = slot.data.listing %}
{% endif %}
{% if listing.total > 0 %}
{% block element_product_listing_count %}
{# TODO: update counter on sorting or filter change #}
<div class="products-counter" data-products-counter="true">
{{ "chespackTheme.category.counter"|trans({
'%items%': listing.elements|length,
'%total%': listing.total
})|raw }}
</div>
{% endblock %}
{% endif %}