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 currentPath = app.request.uri %}
  9. {% set articlePicture = domain ~ "/uploads/cover_default.png" %}
  10. {% set articlePictureWidth = 500 %}
  11. {% set articlePictureHeight = 315 %}
  12. {% if article.image is not null %}
  13. {% set articlePicture = domain ~ vich_uploader_asset(article, 'imageFile') %}
  14. {% if article.image.dimensions[0] is defined %}
  15. {% set articlePictureWidth = article.image.dimensions[0] %}
  16. {% endif %}
  17. {% if article.image.dimensions[1] is defined %}
  18. {% set articlePictureHeight = article.image.dimensions[1] %}
  19. {% endif %}
  20. {% endif %}
  21. <meta property="og:site_name" content="{{ websitename }}" />
  22. <meta property="og:locale" content="{{ locale }}" />
  23. <meta property="og:type" content="{{ social_type }}" />
  24. <meta property="og:title" content="{{ article.title }}" />
  25. <meta property="og:url" content="{{ currentPath }}" />
  26. <meta property="og:description" content="{{ article.shortDescription }}" />
  27. <meta property="og:image" content="{{ articlePicture }}" />
  28. <meta property="og:image:secure_url" content="{{ articlePicture }}" />
  29. <meta property="og:image:width" content="{{ articlePictureWidth }}" />
  30. <meta property="og:image:height" content="{{ articlePictureHeight }}" />
  31. <meta name="twitter:card" content="summary_large_image" />
  32. <meta name="twitter:site" content="{{ twitterSite }}" />
  33. <meta name="twitter:creator" content="{{ twitterCreator }}" />
  34. <meta name="twitter:title" content="{{ article.shortTitle }}" />
  35. <meta name="twitter:description" content="{{ article.shortDescription }}" />
  36. <meta name="twitter:image" content="{{ articlePicture }}" />
  37. <meta name="twitter:image:alt" content="{{ article.shortTitle }}" />
  38. <meta name="twitter:domain" content="{{ removehttps(domain) }}" />
  39. <meta property="article:published_time" content="{{ article.publishedAt|date("Y-m-d") }}" />
  40. <meta property="article:modified_time" content="{{ article.updatedAt|date("Y-m-d") }}">
  41. {% if article.author is not null %}
  42. <meta property="article:author" content="{{ article.author }}" />
  43. {% else %}
  44. <meta property="article:author" content="{{ websitename }}" />
  45. {% endif %}
  46. {% if app.request.locale == "en" %}
  47. {% set urlArticle = path('blog_article',{'slug': article.slug}) %}
  48. {% if article.pageslug3 is not empty %}
  49. {% set urlArticle = '/' ~ article.pageslug ~ '/' ~ article.pageslug2 ~ '/' ~ article.pageslug3 %}
  50. {% elseif article.pageslug2 is not empty %}
  51. {% set urlArticle = '/' ~ article.pageslug ~ '/' ~ article.pageslug2 %}
  52. {% elseif article.pageslug is not empty %}
  53. {% set urlArticle = '/' ~ article.pageslug %}
  54. {% endif %}
  55. {% else %}
  56. {% set urlArticle = path('locale_blog_article',{'_locale':app.request.locale,'slug': article.slug}) %}
  57. {% if article.pageslug3 is not empty %}
  58. {% set urlArticle = '/' ~ app.request.locale ~ '/' ~ article.pageslug ~ '/' ~ article.pageslug2 ~ '/' ~ article.pageslug3 %}
  59. {% elseif article.pageslug2 is not empty %}
  60. {% set urlArticle = '/' ~ app.request.locale ~ '/' ~ article.pageslug ~ '/' ~ article.pageslug2 %}
  61. {% elseif article.pageslug is not empty %}
  62. {% set urlArticle = '/' ~ app.request.locale ~ '/' ~ article.pageslug %}
  63. {% endif %}
  64. {% endif %}
  65. <script type="application/ld+json">
  66. {
  67. "@context":"https://schema.org",
  68. "@type":"NewsArticle",
  69. "mainEntityOfPage":{
  70. "@type":"WebPage",
  71. "@id":"{{ domain ~ urlArticle }}"
  72. },
  73. "headline": {{ article.title|json_encode|raw }},
  74. "dateCreated":"{{ article.publishedAt|date("c") }}",
  75. "datePublished":"{{ article.publishedAt|date("c") }}",
  76. "dateModified":"{{ article.publishedAt|date("c") }}",
  77. "publisher":{
  78. "@type":"Organization",
  79. "name":{{ enterpriseName|json_encode|raw }},
  80. "logo":{
  81. "@type":"ImageObject",
  82. "url":"{{ domain ~ logo }}",
  83. "width":"{{ logo_width }}",
  84. "height":"{{ logo_height }}"
  85. }
  86. },
  87. "description":{{ article.shortDescription|json_encode|raw }},
  88. {% if (article.author is not null) or (article.author is not empty) %}
  89. "author":[{
  90. "@type":"Person",
  91. "name":{{ article.author|json_encode|raw }}
  92. }],
  93. {% endif %}
  94. "image":{
  95. "@type":"ImageObject",
  96. "url":"{{ articlePicture }}",
  97. "width":"{{ articlePictureWidth }}",
  98. "height":"{{ articlePictureHeight }}"
  99. }
  100. }
  101. </script>