templates/front/acheter/_sort.html.twig line 1

Open in your IDE?
  1. {% if context == 'select' %}
  2. <form autocomplete="off" class="d-inline">
  3.     <select class=" sort_estate custom-select {{ class }}">
  4.         {# <option value="si_mandatexclusif-DESC" {% if sort_by == 'si_mandatexclusif-DESC' %}selected="selected"{% endif %}>Exclusivité</option> #}
  5.         <option value="numeromandat-DESC"  {% if sort_by == 'numeromandat-DESC' %}selected="selected"{% endif %}>+ Récent</option>
  6.         <option value="numeromandat-ASC" {% if sort_by == 'numeromandat-ASC' %}selected="selected"{% endif %}>- Récent</option>        
  7.         <option value="prix-DESC" {% if sort_by == 'prix-DESC' %}selected="selected"{% endif %} >Prix ↓</option>
  8.         <option value="prix-ASC" {% if sort_by == 'prix-ASC' %}selected="selected"{% endif %}>Prix ↑</option>
  9.     </select>
  10. </form>
  11. {% elseif context == 'desktop' %}
  12. {# Dropdown custom pour tri #}
  13. <div class="sort_estate_dropdown custom-dropdown d-inline">
  14.     <button class="btn" type="button" id="dropdownSort" data-bs-toggle="dropdown">
  15.         {% set labels = {
  16.             'numeromandat-DESC': '+ Récent',
  17.             'numeromandat-ASC': '- Récent',
  18.             'prix-DESC': 'Prix ↓',
  19.             'prix-ASC': 'Prix ↑',
  20.         } %}
  21.         <span id="sortLabel">{{ labels[sort_by]|default('Trier') }}</span>
  22.         <span class="icon"></span>
  23.     </button>
  24.     <ul class="dropdown-menu" aria-labelledby="dropdownSort">
  25.         {% for value, label in labels %}
  26.             <li>
  27.                 <a href="#" class="dropdown-item {% if sort_by == value %}active text-white bg-primary{% endif %}" data-value="{{ value }}">
  28.                     {{ label }}
  29.                 </a>
  30.             </li>
  31.         {% endfor %}
  32.     </ul>
  33. </div>
  34. {# <script type="text/javascript">
  35.     $(document).ready(function() {
  36.     $('.dropdown-item').click(function(e) {
  37.         e.preventDefault();
  38.         var value = $(this).data('value');
  39.         var label = $(this).text();
  40.         // Mettre à jour le champ caché
  41.         $('#sort_by').val(value);
  42.         // Mettre à jour le texte du bouton (sans toucher le SVG)
  43.         $('#sortLabel').text(label);
  44.         // Mettre à jour l'option active
  45.         $('.dropdown-item').removeClass('active text-white bg-primary');
  46.         $(this).addClass('active text-white bg-primary');
  47.     });
  48. });
  49. </script> #}
  50. {% endif %}