custom/static-plugins/NdTheme/src/Resources/views/storefront/component/custom-sorting.html.twig line 1

Open in your IDE?
  1. {# NOTE #}
  2. {# This file is a duplciate of the @Storefront/storefront/component/sorting.html.twig #}
  3. {# But due to an issue where we can't have this Sorting element twice in the DOM, we have duplciated into a seperate file. #}
  4. {# From here, we give the Sorting a different name and have it trigger the original sorting via a Javascript plugin. #}
  5. {% set config = { sorting: current } %}
  6. {% set showSorting = (slot.config.showSorting.value is defined) ? slot.config.showSorting.value : true %}
  7. {% if showSorting and sortings|length > 1 %}
  8.     <div class="sorting" data-mimic-sorting="[data-list-sorting]" data-mimic-type="{{ type }}">
  9.         {% if type == 'select' %}
  10.             <select class="sorting pr-8 {{ formSelectClass }}"
  11.                     aria-label="{{ 'general.sortingLabel'|trans|striptags }}">
  12.                 {% for sorting in sortings %}
  13.                     {% set key = sorting.key %}
  14.                     <option value="{{ key }}"{% if key == current %} selected{% endif %}>{{ sorting.translated.label|sw_sanitize }}</option>
  15.                 {% endfor %}
  16.             </select>
  17.         {% elseif type == 'button' %}
  18.             <div class="flex overflow-x-scroll grid-gap-2">
  19.                 {% for sorting in sortings %}
  20.                     {% set key = sorting.key %}
  21.                     <div class="radio-container first:ml-4 last:mr-4">
  22.                         <input type="radio" class="hidden peer" name="mimic-sorting" id="{{ key }}"
  23.                                value="{{ key }}" {% if key == current %} checked="checked"{% endif %}>
  24.                         <label for="{{ key }}"
  25.                                class="btn btn-secondary whitespace-nowrap transition peer-checked:bg-grey-900 peer-checked:text-white hover:bg-grey-900 hover:text-white">{{ sorting.translated.label|sw_sanitize }}</label>
  26.                     </div>
  27.                 {% endfor %}
  28.             </div>
  29.         {% endif %}
  30.     </div>
  31. {% endif %}