theme/templates/layouts/news/news.default.html.twig line 1

Open in your IDE?
  1. {% import 'blocks/macros.html.twig' as macros %}
  2. {% extends 'layouts\\base.html.twig' %}
  3. {% block head %}
  4.     {% embed 'partials\\head.html.twig'%}
  5.         {% block ogtype %}article{% endblock %}
  6.     {% endembed %}
  7.     
  8.     {# JSON-LD NewsArticle #}
  9.     {% set data = {
  10.     '@context': 'https://schema.org',
  11.     '@type': 'NewsArticle',
  12.     headline: title|default(''),
  13.     publisher: {
  14.         '@type': 'Organization',
  15.         name: 'Conta lá',
  16.         logo: {
  17.         '@type': 'ImageObject',
  18.         url: CDN_URL|default('') ~ get_config('logo_mobile','')|default('')
  19.         }
  20.     },
  21.     datePublished: page.publishDate ? page.publishDate|date('c') : '',
  22.     mainEntityOfPage: {
  23.         '@type': 'WebPage',
  24.         '@id': app.request.getSchemeAndHttpHost() ~ canonicalUrl|raw
  25.     }
  26.     } %}
  27.     {# Image #}
  28.     {% if default_image|default %}
  29.     {% set data = data|merge({ image: default_image|imagine_filter('news')|urldecode }) %}
  30.     {% endif %}
  31.     {# Authors #}
  32.     {% if page.pageAuthors|length > 0 %}
  33.     {% set authors = [] %}
  34.     {% for author in page.pageAuthors %}
  35.         {% set authors = authors|merge([{ '@type': 'Person', name: author.name|default('') }]) %}
  36.     {% endfor %}
  37.     {% set data = data|merge({ author: authors }) %}
  38.     {% endif %}
  39.     {# Render #}
  40.     <script type="application/ld+json">{{ data|json_encode(constant('JSON_UNESCAPED_SLASHES'))|raw }}</script>
  41.     
  42.     {{ encore_entry_link_tags('news') }}
  43. {% endblock %}
  44. {% block body_class %} class="white-layout"{% endblock %}
  45. {% block content %}
  46. {% set exclusiveTag = page.tags|filter(t => t.domainValue.type.name == 'Exclusive')|first|default(null) %}
  47. {% set repeatable = _repeatable|default([]) %}
  48. {# New structure: repeatable is an array of groups, each group contains all fields for that item #}
  49. {% set hasGallery = repeatable|length > 0 %}
  50. {% set repeatableCount = repeatable|length %}
  51.     <section class="block-contenttype-content">
  52.         <div class="container ">
  53.             <article class="row">
  54.                 <div class="col-12 col-lg-auto order-3 order-lg-1">
  55.                     <div class="social-share">
  56.                         {% set shareUrl = (app.request.getSchemeAndHttpHost() ~ app.request.requestUri)|url_encode %}
  57.                         {% set shareText = (title|default('') ~ ' ' ~ (app.request.getSchemeAndHttpHost() ~ app.request.requestUri))|url_encode %}
  58.                         {# FACEBOOK #}
  59.                         <a href="https://www.facebook.com/sharer.php?u={{ shareUrl }}"
  60.                         target="_blank" rel="noopener noreferrer" title="Partilha no Facebook">
  61.                             {{ file_get_contents(asset('custom/social-share/facebook.svg', 'global'))|raw }}
  62.                         </a>
  63.                         {# WHATSAPP #}
  64.                         <a href="{% if is_mobile() %}
  65.                                     whatsapp://send?text={{ shareText }}
  66.                                 {% else %}
  67.                                     https://api.whatsapp.com/send?text={{ shareText }}
  68.                                 {% endif %}"
  69.                         target="_blank" rel="noopener noreferrer" title="Partilha no WhatsApp">
  70.                             {{ file_get_contents(asset('custom/social-share/whatsapp.svg', 'global'))|raw }}
  71.                         </a>
  72.                         {# X (Twitter) #}
  73.                         <a href="https://twitter.com/intent/tweet?url={{ shareUrl }}&text={{ title|default('')|url_encode }}"
  74.                         target="_blank" rel="noopener noreferrer" title="Partilha no X">
  75.                             {{ file_get_contents(asset('custom/social-share/x.svg', 'global'))|raw }}
  76.                         </a>
  77.                         {# <a href="https://www.linkedin.com/cws/share?url={{app.request.getSchemeAndHttpHost()~app.request.requestUri}}" target="_blank"><i class="fab fa-linkedin" aria-hidden="true"></i></a> #}
  78.                         {# <a href="mailto:info@example.com?&subject=&cc=&bcc=&body={{ app.request.uri }}%0A" target="_blank">
  79.                             <i class="fa fa-envelope"></i>
  80.                         </a> #}
  81.                         <input type="text" id="urlpage" class="d-none" value="{{app.request.getSchemeAndHttpHost()~app.request.requestUri}}">
  82.                         <a href="{{app.request.getSchemeAndHttpHost()~app.request.requestUri}}" target="_blank" class="copyclipboard">
  83.                             {{ file_get_contents(asset('custom/social-share/url.svg', 'global'))|raw }}
  84.                         </a>
  85.                     </div>
  86.                 </div>
  87.                 <div class="col order-2">
  88.                     <h1>{{title|default}}</h1>                   
  89.                     {% set pageInfo = get_page_info(app.request.locale, page.id, true, "Temas") %}
  90.                     {% set categories = pageInfo.categories|default %}
  91.                     {# ------ TEMAS ----- #}
  92.                     {% set maxVisible = 10 %}
  93.                     {% if categories or exclusiveTag %}
  94.                         <div class="categories">
  95.                             {{ macros.renderCategoryPopover(categories, maxVisible, false, exclusiveTag, languagecode,'',false) }}
  96.                         </div>
  97.                     {% endif %}
  98.                     {% if short_text|default %}
  99.                         <div id="shorttext" class="fullcontent">
  100.                             {{ short_text|raw }}
  101.                         </div>
  102.                     {% endif %}
  103.                     {# ------ AUTHORS ----- #}
  104.                     {% include 'partials/elements/authors.twig' %}
  105.                     {% if date|default and hide_date|default != '1' %}
  106.                     {% set tz = 'Europe/Lisbon' %}
  107.                     {% set dateToShow = pageInfo.page.publishDate|default(date) %}
  108.                     {# 24h para pt/es; 12h com AM/PM para en #}
  109.                     {% set fmt = app.request.locale starts with('en') ? 'MMM dd yyyy, HH:mm' : 'dd MMM yyyy, HH:mm' %}
  110.                     <div class="date time">
  111.                         {{ file_get_contents(asset('custom/time-icon.svg', 'global'))|raw }}
  112.                         {{ dateToShow|localizeddate('none', 'none', app.request.locale, tz, fmt) }}
  113.                     </div>
  114.                     {% endif %}
  115.                     {% if full_text|default %}
  116.                         <hr>
  117.                         <div class="d-flex align-items-center justify-content-between mb-3">
  118.                             <button id="textSizeBtn" aria-label="{{ 'change_text_size'|trans ({},'custom' )|html_entity_decode|raw }}" class="text-size" >
  119.                                 <span aria-hidden="true">{{ file_get_contents(asset('custom/fontsize-icon.svg', 'global'))|raw }}</span>
  120.                                 <div>{{ 'text_size'|trans ({},'custom' )|html_entity_decode|raw }}</div>
  121.                                 <div id="popover">
  122.                                     <div class="option" data-size="small" onclick="handleTextSizeChange('small')"><span class="small">A</span> {{ 'small'|trans ({},'custom' )|html_entity_decode|raw }}</div>
  123.                                     <div class="option" data-size="medium" onclick="handleTextSizeChange('medium')"><span class="medium">A</span> {{ 'medium'|trans ({},'custom' )|html_entity_decode|raw }}</div>
  124.                                     <div class="option" data-size="large" onclick="handleTextSizeChange('large')"><span class="large">A</span> {{ 'large'|trans ({},'custom' )|html_entity_decode|raw }}</div>
  125.                                 </div>
  126.                             </button>
  127.                             <button class="read-fullcontent" aria-label="{{ 'listen_publication_content'|trans ({},'custom' )|html_entity_decode|raw }}" data-lang="{{ app.request.locale }}-{{ app.request.locale|upper }}" data-minutes="{{ 'minutes'|trans ({},'custom' )|html_entity_decode|raw }}" data-seconds="{{ 'seconds'|trans ({},'custom' )|html_entity_decode|raw }}">
  128.                                 <span aria-hidden="true">{{ file_get_contents(asset('custom/sound-icon.svg', 'global'))|raw }}</span>
  129.                                 <div>
  130.                                     {{ 'listening'|trans ({},'custom' )|html_entity_decode|raw }} (<span class="timeread"></span>)
  131.                                 </div>
  132.                             </button>
  133.                         </div>
  134.                     {% endif %}
  135.                     {# ===== MEDIA SECTION ===== #}
  136.                     {# Preparar variáveis de imagem default #}
  137.                     {% if is_mobile() %}
  138.                         {% set defaultimage = default_image_mobile|default(default_image|default('')) %}
  139.                         {% set defaultimage_alt = default_image_mobile_alt|default(default_image_alt|default('')) %}
  140.                         {% set defaultimage_title = default_image_mobile_title|default(default_image_title|default('')) %}
  141.                         {% set imageFilter = 'small' %}
  142.                     {% else %}
  143.                         {% set defaultimage = default_image|default(default_image_mobile|default('')) %}
  144.                         {% set defaultimage_alt = default_image_alt|default(default_image_mobile_alt|default('')) %}
  145.                         {% set defaultimage_title = default_image_title|default(default_image_mobile_title|default('')) %}
  146.                         {% set imageFilter = 'news' %}
  147.                     {% endif %}
  148.                     {# Determinar se existe media principal (vídeo tem prioridade) #}
  149.                     {% set hasMainVideo = video_youtubeid|default %}
  150.                     {% set hasMainImage = defaultimage|default %}
  151.                     {% set hasMainMedia = hasMainVideo or hasMainImage %}
  152.                     {% if hasMainMedia or hasGallery %}
  153.                         {% if hasGallery %}
  154.                             {# COM GALERIA - Slider #}
  155.                             <div class="slick-carousel news-media-slider" data-slick='{"dots":true,"arrows":true,"adaptiveHeight":false}'>
  156.                                 {# Slide 1: Vídeo principal OU Imagem principal #}
  157.                                 {% if hasMainVideo %}
  158.                                     <div>
  159.                                         <div class="news-media-frame">
  160.                                             <div class="plyr__video-embed video-player">
  161.                                                 <iframe
  162.                                                     src="https://www.youtube.com/embed/{{ video_youtubeid }}?origin={{ app.request.getSchemeAndHttpHost()|url_encode }}&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1&amp;mute=1"
  163.                                                     allowfullscreen
  164.                                                     allowtransparency
  165.                                                     allow="autoplay; encrypted-media; fullscreen; picture-in-picture"
  166.                                                 ></iframe>
  167.                                             </div>
  168.                                         </div>
  169.                                         {% if video_thumb_title|default %}
  170.                                             <div class="media-alt">{{ video_thumb_title|raw }}</div>
  171.                                         {% endif %}
  172.                                     </div>
  173.                                 {% elseif hasMainImage %}
  174.                                     <div>
  175.                                         <div class="news-media-frame">
  176.                                             <img loading="lazy" src="{{ defaultimage|imagine_filter(imageFilter)|urldecode }}" alt="{{ defaultimage_alt }}" title="{{ defaultimage_title }}" class="img-fluid">
  177.                                         </div>
  178.                                         {% if defaultimage_title %}
  179.                                             <div class="media-alt">{{ 'photography'|trans({},'custom') }} {{ defaultimage_title|raw }}</div>
  180.                                         {% endif %}
  181.                                     </div>
  182.                                 {% endif %}
  183.                                 {# Slides da galeria #}
  184.                                 {% for item in repeatable %}
  185.                                     {% set youtubeId = item.gallery_video_id|default('') %}
  186.                                     {% if youtubeId %}
  187.                                         {# Slide de vídeo #}
  188.                                         <div>
  189.                                             <div class="news-media-frame">
  190.                                                 <div class="plyr__video-embed video-player">
  191.                                                     <iframe
  192.                                                         src="https://www.youtube.com/embed/{{ youtubeId }}?origin={{ app.request.getSchemeAndHttpHost()|url_encode }}&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1&amp;mute=1"
  193.                                                         allowfullscreen
  194.                                                         allowtransparency
  195.                                                         allow="autoplay; encrypted-media; fullscreen; picture-in-picture"
  196.                                                     ></iframe>
  197.                                                 </div>
  198.                                             </div>
  199.                                             {% if item.gallery_caption|default %}
  200.                                                 <div class="media-alt">{{ item.gallery_caption|raw }}</div>
  201.                                             {% endif %}
  202.                                         </div>
  203.                                     {% else %}
  204.                                         {# Slide de imagem #}
  205.                                         {% if is_mobile() %}
  206.                                             {% set galleryImage = item.gallery_image_mobile|default(item.gallery_image|default('')) %}
  207.                                             {% set galleryImageAlt = item.gallery_image_mobile_alt|default(item.gallery_image_alt|default('')) %}
  208.                                             {% set galleryImageTitle = item.gallery_image_mobile_title|default(item.gallery_image_title|default('')) %}
  209.                                         {% else %}
  210.                                             {% set galleryImage = item.gallery_image|default(item.gallery_image_mobile|default('')) %}
  211.                                             {% set galleryImageAlt = item.gallery_image_alt|default(item.gallery_image_mobile_alt|default('')) %}
  212.                                             {% set galleryImageTitle = item.gallery_image_title|default(item.gallery_image_mobile_title|default('')) %}
  213.                                         {% endif %}
  214.                                         {% if galleryImage %}
  215.                                             <div>
  216.                                                 <div class="news-media-frame">
  217.                                                     <img loading="lazy" src="{{ galleryImage|imagine_filter(imageFilter)|urldecode }}" alt="{{ galleryImageAlt }}" title="{{ galleryImageTitle }}" class="img-fluid">
  218.                                                 </div>
  219.                                                 {% if item.gallery_caption|default %}
  220.                                                     <div class="media-alt">{{ item.gallery_caption|raw }}</div>
  221.                                                 {% endif %}
  222.                                             </div>
  223.                                         {% endif %}
  224.                                     {% endif %}
  225.                                 {% endfor %}
  226.                             </div>
  227.                         {% else %}
  228.                             {# SEM GALERIA - Media único #}
  229.                             {% if hasMainVideo %}
  230.                                 <div class="plyr__video-embed video-player">
  231.                                     <iframe
  232.                                         src="https://www.youtube.com/embed/{{ video_youtubeid }}?origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1{% if video_autoplay|default %}&amp;autoplay=1&amp;muted=1{% endif %}"
  233.                                         allowfullscreen
  234.                                         allowtransparency
  235.                                         {% if video_autoplay|default %}allow="autoplay"{% endif %}
  236.                                     ></iframe>
  237.                                 </div>
  238.                                 {% if video_thumb_title|default %}
  239.                                     <div class="media-alt">{{ video_thumb_title|raw }}</div>
  240.                                 {% endif %}
  241.                             {% elseif hasMainImage %}
  242.                                 <img loading="lazy" src="{{ defaultimage|imagine_filter(imageFilter)|urldecode }}" alt="{{ defaultimage_alt }}" title="{{ defaultimage_title }}" class="img-fluid">
  243.                                 {% if defaultimage_title %}
  244.                                     <div class="media-alt">{{ 'photography'|trans({},'custom') }} {{ defaultimage_title|raw }}</div>
  245.                                 {% endif %}
  246.                             {% endif %}
  247.                         {% endif %}
  248.                     {% endif %}
  249.                     {# ===== END MEDIA SECTION ===== #}
  250.                     {% if full_text|default %}
  251.                         <div id="fulltext" class="fullcontent">
  252.                             {{ full_text|raw }}
  253.                             
  254.                             {# Blocks/content #}
  255.                             <div class="row fullcontent">
  256.                             {{ parent() }}
  257.                             </div>
  258.                         </div>
  259.                     {% endif %}
  260.                     {# Tags #}
  261.                     {% if page.tags|length %}
  262.                         <div class="related-tags">
  263.                             {{ 'related_tags'|trans ({},'custom' )|html_entity_decode|raw }}
  264.                             <div class="tags-list">
  265.                                 {% for tag in page.tags %}
  266.                                     {% set description = tag.domainValue.getLocalizedContents(languagecode).description|default %}
  267.                                     {% set machineName = tag.domainValue.machineName|default %}
  268.                                     <div>
  269.                                         <a
  270.                                             role="button"
  271.                                             data-link="/pt/pesquisa?tags[]={{ machineName|e }}"
  272.                                         >
  273.                                             {{ description }}
  274.                                         </a>
  275.                                     </div>
  276.                                 {% endfor %}
  277.                             </div>
  278.                         </div>
  279.                     {% endif %}
  280.                 </div>
  281.                 <div class="col-12 col-lg-auto order-3 right-column">
  282.                     {% if is_ad_zone_active('halfpage') %}
  283.                     <aside>
  284.                     {% include 'partials/ads-banners/halfpage.html.twig' %}
  285.                     </aside>
  286.                     {% endif %}
  287.                 </div>
  288.             </article>
  289.         </div>
  290.     </section>
  291.     {# Snippet Veja também #}
  292.     {% set snippet = render(controller('App\\Controller\\PageContentController::renderSnippet', {"stdSnippets": get_config('snippet_news',''), "pageId": page.id})) %}
  293.     {% if snippet|default %}
  294.         {{snippet|raw}}
  295.     {% endif %}
  296. {% endblock %}
  297. {% block scripts %}
  298.     {{ parent() }}
  299.     {% if is_ad_zone_active('mrec') %}
  300.     <template id="mrec-template">{% include 'partials/ads-banners/mrec.html.twig' %}</template>
  301.     {{ encore_entry_script_tags('ad-news') }}
  302.     {% endif %}
  303.     {{ encore_entry_script_tags('news') }}
  304. {% endblock %}