templates/common/components/news.html.twig line 1

Open in your IDE?
  1. {% import 'common/macros/elements.html.twig' as elements %}
  2. {% import _self as _ %}
  3. {% macro truncate(text, len) %}
  4.     {% if text|length > len %}
  5.         {{ text|slice(0,len) ~ '...' }}
  6.     {% else %}
  7.         {{ text }}
  8.     {% endif %}
  9. {% endmacro %}
  10. {% macro list_item(post) %}
  11.     {% set href = path('news_show', { news: post.getSlug() }) %}
  12.     <article class="list-item">
  13.         {% if post.coverImagePath is not null %}
  14.             <div class="image">
  15.                 <a href="{{ href }}">
  16.                     <img src="{{ getUploadsUrl(post.coverImagePath) }}" alt="{{ post.getTitle() }}"/>
  17.                 </a>
  18.             </div>
  19.         {% endif %}
  20.         <div class="content">
  21.             {{ elements.heading('<a href="' ~ href ~ '">' ~ getNewsTitle(post) ~ '</a>', 3, 'title') }}
  22.             <p class="text">{{ getNewsShortDescription(post) }}</p>
  23.             {{ elements.CTA('common.read_more'|trans|upper, href, 'link') }}
  24.         </div>
  25.     </article>
  26. {% endmacro %}
  27. <section class="news-section section {{ isSingleNewsPage is defined and isSingleNewsPage ? 'single-news-section' : '' }}">
  28.     <div class="section-header">
  29.         {% if isSingleNewsPage is not defined %}
  30.             {{ elements.heading('common.news'|trans|upper, 4, 'section-category') }}
  31.             {{ elements.heading('common.latest_posts'|trans, 2, 'section-title') }}
  32.         {% else %}
  33.             {{ elements.heading('common.more_news'|trans, 2, 'section-title') }}
  34.         {% endif %}
  35.     </div>
  36.     <div class="list">
  37.         {% for item in items %}
  38.             {{ _.list_item(item) }}
  39.         {% endfor %}
  40.     </div>
  41.     {% if hideMore is not defined %}
  42.         <div class="more">
  43.             {% if more|default('a') == 'a' %}
  44.                 {{ elements.CTA('common.more_news'|trans|upper, path('news_index'), 'secondary') }}
  45.             {% else %}
  46.                 <div class="btn cta-secondary">{{ 'common.more_news'|trans|upper }}</div>
  47.             {% endif %}
  48.         </div>
  49.     {% endif %}
  50. </section>