{% set getAllCategories = getParentCategories() %}
{% extends "base.html.twig" %}
{% block title %}
Recherche
{% endblock %}
{% block stylesheet %}
{{ parent() }}
<link href="{{ asset('assets/css/main.css') }}" rel="stylesheet">
<link href="{{ asset('assets/css/hero-in.css') }}" rel="stylesheet">
{% endblock %}
{% block body %}
{% include '_partials/home/hero-section.html.twig' %}
<!-- /hero_single -->
<main>
<div class="mt-4 container-fluid">
<h1 class="mb-5" style="font-weight: 700">Recherche</h1>
<div class="row mb-5">
<div class="col-sm-12 col-md-4 col-xl-3 col-xxl-3">
{% include "_partials/search/attraction_advanced_search.html.twig" %}
</div>
<div class="col-sm-12 col-md-8 col-xl-9 col-xxl-9">
<div class="w-100 p-0">
{% if attractions | length > 0 %}
<div class="row">
{% for attraction in attractions %}
{% include "_partials/coins/item.html.twig" with {
'attraction': attraction,
'show_categories': true
} %}
{% endfor %}
</div>
<div class="row">
{% if pagination | length > 0 %}
<div class="col-md-4 offset-md-4" style="display: flex; justify-content: center;">
{% include '_partials/pagination.html.twig' with {
total: pagination.last,
current: page,
url: currentUrl ~ "&page="
} %}
</div>
{% endif %}
</div>
{% else %}
<div class="col-12">
<div class="card"
style="border: 1px solid #ffffff; box-shadow: 0px 0px 15px 1px #e3e3e3; background-color: white; border-radius: 10px;">
<div class="card-body">
<h2 class="text-center">Cette recherche n'a donné aucun résultat.</h2>
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</main>
<!--/main-->
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
let monUrl = window.location.href;
function selectedCategory(categoryId) {
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
const selectedCategories = [];
const input = document.querySelector('input[type="checkbox"][value="' + categoryId + '"]');
let isSubcategoryUnchecked = false;
if (input) {
const subInputs = document.querySelectorAll('input[data-parent="' + categoryId + '"]');
if (input.checked) {
subInputs.forEach(subInput => {
subInput.checked = true;
});
} else {
subInputs.forEach(subInput => {
subInput.checked = false;
});
isSubcategoryUnchecked = true; // Trigger page reload if any subcategory is unchecked
}
}
checkboxes.forEach((checkbox) => {
if (checkbox.checked) {
selectedCategories.push(checkbox.value);
}
});
const currentUrl = window.location.href;
const url = new URL(currentUrl);
url.searchParams.delete('categoryId');
if (selectedCategories.length > 0) {
url.searchParams.set('categoryId', selectedCategories.join(','));
}
monUrl = decodeURIComponent(url.toString());
// Actualisation de la page si une sous-catégorie est décochée
if (isSubcategoryUnchecked) {
window.location.replace(monUrl);
}
}
function submitSearch(event) {
event.preventDefault();
window.location.replace(monUrl);
}
function refreshSearchWindow(event) {
event.preventDefault();
window.location.replace(monUrl);
}
</script>
{% endblock %}