templates/vitrine/components/socialmedia_articles.html.twig line 1

Open in your IDE?
  1. {% set paramSocialMedia = getCoreToolsList("socialmedia") %}
  2. {% set twitterSite = paramSocialMedia['twitter_site'] %}
  3. {% set twitterCreator = paramSocialMedia['twitter_creator'] %}
  4. {% set locale = paramSocialMedia['lang_HTML'] %}
  5. {% set websitename = paramSocialMedia['websitename'] %}
  6. {% set domain = paramSocialMedia['absolute_domain'] %}
  7. {% set enterpriseName = paramSocialMedia['enterprise_name'] %}
  8. {% set logo_organization = paramSocialMedia['logo_organization'] %}
  9. {% set size_width_logo_organization = paramSocialMedia['size_width_logo_organization'] %}
  10. {% set size_height_logo_organization = paramSocialMedia['size_height_logo_organization'] %}
  11. {% set currentPath = app.request.uri %}
  12. <meta property="og:site_name" content="{{ websitename }}" />
  13. <meta property="og:locale" content="{{ app.request.locale }}" />
  14. <meta property="og:type" content="{{ social_type }}" />
  15. <meta property="og:title" content="{{ article.title }}" />
  16. <meta property="og:url" content="{{ currentPath }}" />
  17. <meta property="og:description" content="{{ article.shortDescription }}" />
  18. {% if article.image.name is not null %}
  19.     {% set social_picture = domain ~ vich_uploader_asset(article, 'imageFile') %}
  20.     <meta property="og:image" content="{{ social_picture }}" />
  21.     <meta property="og:image:secure_url" content="{{ social_picture }}" />
  22.     {% if article.image.dimensions[0] is defined %}<meta property="og:image:width" content="{{ article.image.dimensions[0] }}" />{% endif %}
  23.     {% if article.image.dimensions[1] is defined %}<meta property="og:image:height" content="{{ article.image.dimensions[1] }}" />{% endif %}
  24. {% endif %}
  25. <meta name="twitter:card" content="summary_large_image" />
  26. <meta name="twitter:site" content="{{ twitterSite }}" />
  27. <meta name="twitter:creator" content="{{ twitterCreator }}" />
  28. <meta name="twitter:title" content="{{ article.title }}" />
  29. <meta name="twitter:description" content="{{ article.shortDescription }}" />
  30. {% if article.image.name is not null %}
  31.     <meta name="twitter:image" content="{{ social_picture }}" />
  32.     <meta name="twitter:image:alt" content="{{ article.shortTitle }}" />
  33. {% endif %}
  34. <meta name="twitter:domain" content="{{ removehttps(domain) }}" />
  35. <meta property="article:published_time" content="{{ article.publishedAt|date("Y-m-d") }}" />
  36. <meta property="article:modified_time" content="{{ article.updatedAt|date("Y-m-d") }}">
  37. {% if article.author is not null %}
  38.     <meta property="article:author" content="{{ article.author }}" />
  39. {% else %}
  40.     <meta property="article:author" content="{{ websitename }}" />
  41. {% endif %}
  42. {% set prefix = "" %}
  43. {% set urlArticle = path('blog_article',{'slug': article.slug})  %}
  44. {% if app.request.locale != "en" %}
  45.     {% set urlArticle = path('locale_blog_article',{'_locale':app.request.locale,'slug': article.slug})  %}
  46.     {% set prefix = "/" ~ app.request.locale %}
  47. {% endif %}
  48. {% if article.pageslug3 is not empty %}
  49.     {% set urlArticle = prefix ~ '/' ~ article.pageslug ~ '/' ~  article.pageslug2 ~ '/' ~ article.pageslug3  %}
  50. {% elseif article.pageslug2 is not empty %}
  51.     {% set urlArticle = prefix ~ '/' ~ article.pageslug ~ '/' ~  article.pageslug2  %}
  52. {% elseif article.pageslug is not empty %}
  53.     {% set urlArticle =  prefix ~ '/' ~ article.pageslug  %}
  54. {% endif %}
  55. <script type="application/ld+json">
  56.     {
  57.         "@context": "https://schema.org",
  58.         "@type": "Article",
  59.         "mainEntityOfPage": {
  60.             "@type": "WebPage",
  61.             "@id": "{{ domain ~ urlArticle }}"
  62.         },
  63.         "headline": {{ article.title|json_encode|raw }},
  64.         "dateCreated": "{{ article.publishedAt|date("c") }}",
  65.         "datePublished": "{{ article.publishedAt|date("c") }}",
  66.         "dateModified": "{{ article.updatedAt|date("c") }}",
  67.         "publisher": {
  68.             "@type": "Organization",
  69.             "name": {{ enterpriseName|json_encode|raw }},
  70.             "logo": {
  71.                 "@type": "ImageObject",
  72.                 "url": "{{ domain ~ logo_organization }}",
  73.                 "width": "{{ size_width_logo_organization }}",
  74.                 "height": "{{ size_height_logo_organization }}"
  75.             }
  76.         },
  77.         "description": {{ article.shortDescription|json_encode|raw }}{% if (article.author is not null) and (article.author is not empty) %},
  78.         "author": [{
  79.             "@type": "Person",
  80.             "name": {{ article.author|json_encode|raw }}
  81.         }]{% endif %}{% if article.image.name is not null %},
  82.         "image": {
  83.             "@type": "ImageObject",
  84.             "url": "{{ social_picture }}",
  85.             "width": "{{ article.image.dimensions[0] }}",
  86.             "height": "{{ article.image.dimensions[1] }}"
  87.         }{% endif %}
  88.     }
  89. </script>