templates/frontend/search/search.html.twig line 1

Open in your IDE?
  1. {% set getAllCategories = getParentCategories() %}
  2. {% extends "base.html.twig" %}
  3. {% block title %}
  4.     Recherche
  5. {% endblock %}
  6. {% block stylesheet %}
  7.     {{ parent() }}
  8.     <link href="{{ asset('assets/css/main.css') }}" rel="stylesheet">
  9.     <link href="{{ asset('assets/css/hero-in.css') }}" rel="stylesheet">
  10. {% endblock %}
  11. {% block body %}
  12.     {% include '_partials/home/hero-section.html.twig' %}
  13.     <!-- /hero_single -->
  14.     <main>
  15.         <div class="mt-4 container-fluid">
  16.             <h1 class="mb-5" style="font-weight: 700">Recherche</h1>
  17.             <div class="row mb-5">
  18.                 <div class="col-sm-12 col-md-4 col-xl-3 col-xxl-3">
  19.                     {% include "_partials/search/attraction_advanced_search.html.twig" %}
  20.                 </div>
  21.                 <div class="col-sm-12 col-md-8 col-xl-9 col-xxl-9">
  22.                     <div class="w-100 p-0">
  23.                         {% if attractions | length > 0 %}
  24.                             <div class="row">
  25.                                 {% for attraction in attractions %}
  26.                                     {% include "_partials/coins/item.html.twig" with {
  27.                                         'attraction': attraction,
  28.                                         'show_categories': true
  29.                                     } %}
  30.                                 {% endfor %}
  31.                             </div>
  32.                             <div class="row">
  33.                                 {% if pagination | length > 0 %}
  34.                                     <div class="col-md-4 offset-md-4" style="display: flex; justify-content: center;">
  35.                                         {% include '_partials/pagination.html.twig' with {
  36.                                             total: pagination.last,
  37.                                             current: page,
  38.                                             url: currentUrl ~ "&page="
  39.                                         } %}
  40.                                     </div>
  41.                                 {% endif %}
  42.                             </div>
  43.                         {% else %}
  44.                             <div class="col-12">
  45.                                 <div class="card"
  46.                                      style="border: 1px solid #ffffff; box-shadow: 0px 0px 15px 1px #e3e3e3; background-color: white; border-radius: 10px;">
  47.                                     <div class="card-body">
  48.                                         <h2 class="text-center">Cette recherche n'a donné aucun résultat.</h2>
  49.                                     </div>
  50.                                 </div>
  51.                             </div>
  52.                         {% endif %}
  53.                     </div>
  54.                 </div>
  55.             </div>
  56.         </div>
  57.     </main>
  58.     <!--/main-->
  59. {% endblock %}
  60. {% block javascripts %}
  61.     {{ parent() }}
  62.     <script type="text/javascript">
  63.         let monUrl = window.location.href;
  64.         function selectedCategory(categoryId) {
  65.             const checkboxes = document.querySelectorAll('input[type="checkbox"]');
  66.             const selectedCategories = [];
  67.             const input = document.querySelector('input[type="checkbox"][value="' + categoryId + '"]');
  68.             let isSubcategoryUnchecked = false;
  69.             if (input) {
  70.                 const subInputs = document.querySelectorAll('input[data-parent="' + categoryId + '"]');
  71.                 if (input.checked) {
  72.                     subInputs.forEach(subInput => {
  73.                         subInput.checked = true;
  74.                     });
  75.                 } else {
  76.                     subInputs.forEach(subInput => {
  77.                         subInput.checked = false;
  78.                     });
  79.                     isSubcategoryUnchecked = true; // Trigger page reload if any subcategory is unchecked
  80.                 }
  81.             }
  82.             checkboxes.forEach((checkbox) => {
  83.                 if (checkbox.checked) {
  84.                     selectedCategories.push(checkbox.value);
  85.                 }
  86.             });
  87.             const currentUrl = window.location.href;
  88.             const url = new URL(currentUrl);
  89.             url.searchParams.delete('categoryId');
  90.             if (selectedCategories.length > 0) {
  91.                 url.searchParams.set('categoryId', selectedCategories.join(','));
  92.             }
  93.             monUrl = decodeURIComponent(url.toString());
  94.             // Actualisation de la page si une sous-catégorie est décochée
  95.             if (isSubcategoryUnchecked) {
  96.                 window.location.replace(monUrl);
  97.             }
  98.         }
  99.         function submitSearch(event) {
  100.             event.preventDefault();
  101.             window.location.replace(monUrl);
  102.         }
  103.         function refreshSearchWindow(event) {
  104.             event.preventDefault();
  105.             window.location.replace(monUrl);
  106.         }
  107.     </script>
  108. {% endblock %}