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

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