templates/api/blocks/api_search_render.html.twig line 1

Open in your IDE?
  1. {% set article = safe_content_load(id) %}
  2. {% if article is not null %}
  3. {% if article.author is defined and article.author is not empty and
  4.     article.author.contact is defined and article.author.contact is not empty %}
  5.     {% set author = sulu_resolve_user(article.author).contact.fullName %}
  6. {% endif %}
  7. {% if article.content is defined and article.content is not empty %}
  8.     {% set articleContent = article.content %}
  9. {% endif %}
  10. {% if article.extension.excerpt.categories is defined and article.extension.excerpt.categories is not empty %}
  11.     {% set categories = article.extension.excerpt.categories %}
  12. {% endif %}
  13. {% if articleContent.chapo is defined and articleContent.chapo is not empty %}
  14.     {% set chapo = articleContent.chapo %}
  15. {% endif %}
  16. {% if articleContent.routePath is defined and articleContent.routePath is not empty %}
  17.     {% set routePath = articleContent.routePath %}
  18. {% endif %}
  19. {% if articleContent.title is defined and articleContent.title is not empty %}
  20.     {% set title = articleContent.title %}
  21. {% endif %}
  22. {% if articleContent.front_title is defined and articleContent.front_title is not empty %}
  23.     {% set title = articleContent.front_title %}
  24. {% endif %}
  25. {% if article.template is defined and article.template is not empty %}
  26.     {# 
  27.                 category = {
  28.                     id: number, 
  29.                     key: string, 
  30.                     name: string, 
  31.                     description: ?string, 
  32.                     meta: array, 
  33.                     keywords: array, 
  34.                     defaultLocale: string,
  35.                     creator: string,
  36.                     changer: string,
  37.                     created: Datetime,
  38.                     changed: Datetime
  39.                 }
  40.             #}
  41.     {% set them_ids = [] %}
  42.     {% for category in article.extension.excerpt.categories %}
  43.         {% set them_ids = them_ids|merge([category.id]) %}
  44.     {% endfor %}
  45.     {% set categoryColor = '' %}
  46.     {% if them_ids[0] is defined and them_ids[0] is not null %}
  47.         {% set categoryColor = load_category_by_id(them_ids[0], 'fr').entity.color %}
  48.     {% endif %}
  49.     {% if article.content.main_category is defined and article.content.main_category is not empty %}
  50.         {% set categoryColor = load_category_by_id(article.content.main_category.id, 'fr').entity.color %}
  51.     {% endif %}
  52.     {% set categoryColor = categoryColor ?: '#354161' %}
  53.     {% set type_territoire = '' %}
  54.     {% if article.type_territoire is defined and article.type_territoire is not empty %}
  55.         {% set type_territoire = article.type_territoire %}
  56.     {% endif %}
  57.     <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 %}>
  58.         {% if article.template == "articles" or article.template == "analyses" or article.template == "guides_outils" %}
  59.             {% include "api/blocks/articles-preview-content.html.twig" %}
  60.         {% elseif article.template == "agenda" %}
  61.             {% include "api/blocks/agenda-preview-content.html.twig" %}
  62.         {% elseif article.template == "newsletters" %}
  63.             {% include "api/blocks/newsletters-preview-content.html.twig" %}
  64.         {% elseif article.template == "offres" %}
  65.             {% include "api/blocks/offres-preview-content.html.twig" %}
  66.         {% elseif article.template == "aapami" %}
  67.             {% include "api/blocks/aapami-preview-content.html.twig" %}
  68.         {% elseif article.template == "fiches_territoires" %}
  69.         {% if isSearch is defined and isSearch %}
  70.                 {% include "api/blocks/territory-only-preview.html.twig" %}
  71.             {% else %}
  72.                 {% include "api/blocks/territoire-preview-content.html.twig" %}
  73.             {% endif %}
  74.         {% elseif article.template == "experiences" %}
  75.             {% if isSearch is defined and isSearch %}
  76.                 {% include "api/blocks/experience-only-preview.html.twig" %}
  77.             {% else %}
  78.                 {% include "api/blocks/experience-map-preview.html.twig" %}
  79.             {% endif %}
  80.         {% endif %}
  81.     </div>
  82. {% endif %}
  83. {% endif %}