{% set article = sulu_content_load(id) %}
{% if article.author is defined and article.author is not empty and
article.author.contact is defined and article.author.contact is not empty %}
{% set author = sulu_resolve_user(article.author).contact.fullName %}
{% endif %}
{% if article.content is defined and article.content is not empty %}
{% set articleContent = article.content %}
{% endif %}
{% if article.extension.excerpt.categories is defined and article.extension.excerpt.categories is not empty %}
{% set categories = article.extension.excerpt.categories %}
{% endif %}
{% if articleContent.chapo is defined and articleContent.chapo is not empty %}
{% set chapo = articleContent.chapo %}
{% endif %}
{% if articleContent.routePath is defined and articleContent.routePath is not empty %}
{% set routePath = articleContent.routePath %}
{% endif %}
{% if articleContent.title is defined and articleContent.title is not empty %}
{% set title = articleContent.title %}
{% endif %}
{% if articleContent.front_title is defined and articleContent.front_title is not empty %}
{% set title = articleContent.front_title %}
{% endif %}
{% if article.template is defined and article.template is not empty %}
{#
category = {
id: number,
key: string,
name: string,
description: ?string,
meta: array,
keywords: array,
defaultLocale: string,
creator: string,
changer: string,
created: Datetime,
changed: Datetime
}
#}
{% set them_ids = [] %}
{% for category in article.extension.excerpt.categories %}
{% set them_ids = them_ids|merge([category.id]) %}
{% endfor %}
{% set categoryColor = '' %}
{% if them_ids[0] is defined and them_ids[0] is not null %}
{% set categoryColor = load_category_by_id(them_ids[0], 'fr').entity.color %}
{% endif %}
{% if article.content.main_category is defined and article.content.main_category is not empty %}
{% set categoryColor = load_category_by_id(article.content.main_category.id, 'fr').entity.color %}
{% endif %}
{% set categoryColor = categoryColor ?: '#354161' %}
{% set type_territoire = '' %}
{% if article.type_territoire is defined and article.type_territoire is not empty %}
{% set type_territoire = article.type_territoire %}
{% endif %}
<div class="preview-container {{ article.template }} br8 dflex fdc" data-uuid="{{ article.uuid }}" data-theme="{{them_ids|json_encode|raw}}" data-main-color="{{ categoryColor }}" {% if article.content is defined and article.content.title is defined %} data-title="{{ article.content.title }}" {% endif %} {% if article.content is defined and article.content.adresse is defined and article.content.adresse is not empty %} data-lat="{{ article.content.adresse[1] }}" data-long="{{ article.content.adresse[2] }}" {% endif %} {% if article.content is defined and article.content.type_territoire is defined %} data-type="{{ article.content.type_territoire }}" {% endif %} {% if article.content is defined and article.content.header_img is defined and article.content.header_img is not empty %} data-header-img="{{ article.content.header_img.url }}" {% endif %} {% if article.content is defined and article.content.departement is defined and article.content.departement is not empty %} data-departement="{{ article.content.departement }}" {% endif %} {% if article.template == "experiences" or article.template == "fiches_territoires" %} data-html="{{ include('api/api_experience_search.html.twig', { header_img: article.content.header_img, categories: them_ids, departement: article.content.departement, title: title, url: routePath }) | json_encode | base64_encode }}" {% endif %}>
{% if article.template == "articles" or article.template == "analyses" or article.template == "guides_outils" %}
{% include "api/blocks/articles-preview-content.html.twig" %}
{% elseif article.template == "agenda" %}
{% include "api/blocks/agenda-preview-content.html.twig" %}
{% elseif article.template == "newsletters" %}
{% include "api/blocks/newsletters-preview-content.html.twig" %}
{% elseif article.template == "offres" %}
{% include "api/blocks/offres-preview-content.html.twig" %}
{% elseif article.template == "aapami" %}
{% include "api/blocks/aapami-preview-content.html.twig" %}
{% elseif article.template == "fiches_territoires" %}
{% if isSearch is defined and isSearch %}
{% include "api/blocks/territory-only-preview.html.twig" %}
{% else %}
{% include "api/blocks/territoire-preview-content.html.twig" %}
{% endif %}
{% elseif article.template == "experiences" %}
{% if isSearch is defined and isSearch %}
{% include "api/blocks/experience-only-preview.html.twig" %}
{% else %}
{% include "api/blocks/experience-map-preview.html.twig" %}
{% endif %}
{% endif %}
</div>
{% endif %}