{% macro renderTeasersList(method, entities, listWithThumbnails = false) %}
{% set ids = "" %}
{% for entity in entities %}
{% if ids == "" %}
{% set ids = ids ~ entity.id %}
{% else %}
{% set ids = ids ~ "-" ~ entity.id %}
{% endif %}
{% endfor %}
{{ render(controller(method, {'ids': ids, 'listWithThumbnails': listWithThumbnails})) }}
{% endmacro %}
{% import _self as selfm %}
{% if listWithThumbnails is not defined %}
{% set listWithThumbnails = false %}
{% endif %}
<h1>
{% if title is not defined %}
Recherche : {{term}}
{% else %}
{{ title|raw }}
{% endif %}
</h1>
{% if not articles and not events and not questionAnswers and not structures %}
<p>Votre recherche <strong>{{term}}</strong> ne donne aucun résultat.</p>
{% else %}
<p>
Voici les résultats de votre recherche : <strong>{{term}}</strong><br/>
{% if theme is defined and theme is not null and theme.tags is not empty and is_granted('ROLE_EDITOR') %}
Le thème est défini par ces mots-clés : {{ theme.tags|join(", ") }}
{% endif %}
</p>
<div class="resultats-recherche-wrapper">
{#
{{ dump(articles) }}
{{ dump(events) }}
{{ dump(questionAnswers) }}
{{ dump(structures) }}
#}
{% if questionAnswers %}
{{ selfm.renderTeasersList('App\\Controller\\QuestionAnswerController::showSearchResult', questionAnswers, listWithThumbnails) }}
{% endif %}
{% if structures %}
{{ selfm.renderTeasersList('App\\Controller\\StructureController::showSearchResult', structures, listWithThumbnails) }}
{% endif %}
{% if articles %}
{{ selfm.renderTeasersList('App\\Controller\\ArticleController::showSearchResult', articles, listWithThumbnails) }}
{% endif %}
{% if events %}
{{ selfm.renderTeasersList('App\\Controller\\EventController::showSearchResult', events, listWithThumbnails) }}
{% endif %}
</div>
{% endif %}
<p>
Une erreur ? Un complément à ajouter ? <a href="{{ path('contact') }}"><strong>Signalez-le nous !</strong></a>
</p>
<h2>Vous souhaitez faire une autre recherche ?</h2>
<div class="mt-3 mb-4 themes-search">
<p>Faites une <strong>recherche par thème</strong></p>
<div class="row row-cols-lg-6 row-cols-md-4 row-cols-sm-3 row-cols-3 themes">
{{ render(controller('App\\Controller\\ThemeController:showThemes')) }}
</div>
</div>
<div class="recherche">
<p>Ou <strong>tapez un mot-clé</strong></p>
{# {{ form(searchForm) }} #}
{{ render(controller('App\\Controller\\TagController:showTagForm')) }}
<p>
<a href="{{ path('tagsList') }}">Voir la liste des tags</a>
</p>
</div>