{% extends "master.html.twig" %}
{% block meta %}
{% include "@SuluWebsite/Extension/seo.html.twig" with {
"seo": extension.seo|default([]),
"content": content|default([]),
"urls": urls|default([]),
"shadowBaseLocale": shadowBaseLocale|default(),
"defaultLocale": request.defaultLocale|default('de')
} %}
{% endblock %}
{% block style %}
<link rel="stylesheet" href="{{ absolute_url(asset("build/website/css/blog.css")) }}">
{% endblock %}
{% block bgImages %}
{% for image in content.images %}
{{ image.url }}
{% endfor %}
{% endblock %}
{% block ogImages %}{% for image in content.images %}{{ image.url }}{% endfor %}{% endblock %}
{% block content %}
<div class="content-actu">
<div class="filter">
{# define array and merge in if tag name doesn't exist #}
{% set tagsName = [] %}
<div class="filter-tag all active" data-id="empty">
Tout
</div>
{% for article in content.articles %}
{% for tag in article.excerpt.tags %}
{% if tag.name not in tagsName %}
{% set tagsName = tagsName|merge([tag.name]) %}
<div class="filter-tag {{ " " }} {{ tag.name|lower|replace({ 'á':'a', 'é':'e', 'í':'i', 'ó':'o', 'ú':'u' }) }}" data-id="{{ tag.name|lower|replace({ 'á':'a', 'é':'e', 'í':'i', 'ó':'o', 'ú':'u' }) }}">
{{ tag.name|replace({'-':' '}) }}
</div>
{% endif %}
{% endfor %}
{% endfor %}
</div>
<div class="teaser_actus">
{% for article in content.articles %}
{% if article.excerpt.tags|length > 0 %}
<div class="container-article {{ " " }} {% for tag in article.excerpt.tags %}{{ tag.name|lower|replace({ 'á':'a', 'é':'e', 'í':'i', 'ó':'o', 'ú':'u' }) }}{{ " " }}{% endfor %}" style="display: block">
<article class="article">
<a class="img-actu" href="{{ sulu_content_path(article.content.content.routePath) }}">
<div class="tags {{ " " }} {{ article.excerpt.tags|first.name|lower|replace({ 'á':'a', 'é':'e', 'í':'i', 'ó':'o', 'ú':'u' }) }}">{{article.excerpt.tags|first.name|replace({'-':' '})|lower }}</div>
{% if article.content.content.banner %}
<div class="image lazy" data-src="{{ article.content.content.banner[0].url }}"></div>
{% endif %}
</a>
<div>
<div class="date_actu">{{ article.authored|date("d / m / Y") }}</div>
<h2><a href="{{ sulu_content_path(article.content.content.routePath) }}">{{ article.title }}</a></h2>
<button aria-label="more" class="btn btn-light"><a href="{{ sulu_content_path(article.content.content.routePath) }}">En savoir plus</a></button>
</div>
</article>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endblock %}
{% block javascripts %}
<script>
$(document).ready(function() {
function applyTagFilter(tag) {
if (tag === "empty") {
$(".filter .active-tag").removeClass("active-tag");
$(".all").addClass('active');
$(".container-article").show();
} else {
$(".all").removeClass('active');
$(".filter .active-tag").removeClass("active-tag");
$(`[data-id="${tag}"]`).addClass("active-tag");
$(".container-article").show();
var choice = "." + tag;
if (choice) {
$(".container-article").not(choice).hide();
}
}
$(".article").removeClass("right left");
$(".container-article:visible article").each(function(index, el) {
if (index % 2 !== 0) {
$(el).addClass("right");
} else {
$(el).addClass("left");
}
});
}
// Lire l'URL actuelle et appliquer le filtre si un tag est présent
var urlParams = new URLSearchParams(window.location.search);
var initialTag = urlParams.get('tag');
if (initialTag) {
applyTagFilter(initialTag);
}
// Événement pour les clics sur les tags
$('.filter-tag').click(function(e) {
var tag = $(this).attr("data-id");
if (tag === "empty") {
history.pushState(null, '', window.location.pathname);
} else {
history.pushState(null, '', window.location.pathname + '?tag=' + tag);
}
applyTagFilter(tag);
});
// Événement pour la navigation dans l'historique
window.addEventListener('popstate', function() {
var tag = new URLSearchParams(window.location.search).get('tag');
applyTagFilter(tag || "empty");
});
});
</script>
<script>window.breadcrumbMap={'json-ld-breadcrumb':'JSON-LD Breadcrumb'}</script>
{% endblock %}