templates/home/blocks/news.html.twig line 1

Open in your IDE?
  1. {% set datas = {
  2.     'news1': {
  3.         'title': 'news 1',
  4.         'subtitle': 'subtitle',
  5.         'publishedAt': 'now'|date('d/m/Y'),
  6.         'selected': false,
  7.         'images_url': 'https://static.dw.com/image/39323077_401.jpg',
  8.         'contents': {
  9.             0: {
  10.                 'type': 'img',
  11.                 'content': 'https://static.dw.com/image/39323077_401.jpg'
  12.             },
  13.             1: {
  14.                 'type': 'text',
  15.                 'content': 'Content wthwtwhtxhthxthxfthtfx'
  16.             },
  17.             2: {
  18.                 'type': 'img',
  19.                 'content': 'https://static.dw.com/image/39323077_401.jpg'
  20.             },
  21.         }
  22.     },
  23.     'news2': {
  24.         'title': 'news 1',
  25.         'subtitle': 'subtitle',
  26.         'publishedAt': 'now'|date('d/m/Y'),
  27.         'selected': true,
  28.         'images_url': 'https://static.dw.com/image/39323077_401.jpg',
  29.         'contents': {
  30.             1: {
  31.                 'type': 'text',
  32.                 'content': 'Content wthwtwhtxhthxthxfthtfx'
  33.             },
  34.             2: {
  35.                 'type': 'img',
  36.                 'content': 'https://static.dw.com/image/39323077_401.jpg'
  37.             },
  38.         }
  39.     },
  40.     'news3': {
  41.         'title': 'news 3',
  42.         'subtitle': 'subtitle',
  43.         'publishedAt': 'now'|date('d/m/Y'),
  44.         'selected': false,
  45.         'images_url': 'https://static.dw.com/image/39323077_401.jpg',
  46.         'contents': {
  47.             0: {
  48.                 'type': 'img',
  49.                 'content': 'https://static.dw.com/image/39323077_401.jpg'
  50.             },
  51.             1: {
  52.                 'type': 'text',
  53.                 'content': 'Content wthwtwhtxhthxthxfthtfx'
  54.             },
  55.         }
  56.     },
  57. }
  58. %}
  59. {% if data is not defined and app.request.locale == 'en'%}
  60.     {%  set data = {'block_page_id' : 969 ,'title' : 'News'} %}
  61. {%  endif %}
  62. {% if data is defined %}
  63.     {% set news = twig_service.getLatestNews(data.block_page_id) %}
  64.    {% set datas = news|filter_news(news) %}
  65.       {% set isSelected = false %}
  66.      {% set dateNow = 'now'|date('U') %}
  67.      <div class="news">
  68.          <h1 class="title">{{ data.title }}</h1>
  69.          <div class="news-wrapper">
  70.              <div class="scroll">Scroll</div>
  71.              <ul class="items">
  72.                  {% set nbLoop = 1 %}
  73.                  {% for news in datas %}
  74.                      {%  set lang = app.request.locale  %}
  75.                      {%  if app.request.locale == 'en' %}
  76.                          {%  set lang = 'us'  %}
  77.                      {%  endif  %}
  78.                      {%  if lang == news.0.lang_block %}
  79.                          {% set postSelected = false %}
  80.                          {% set datePost = news.0.published_at|date('U') %}
  81.                          {% if datePost > dateNow and not isSelected %}
  82.                              {% set isSelected = true %}
  83.                              {% set postSelected = true %}
  84.                          {% endif %}
  85.                          {% include 'home/blocks/news_single.html.twig' with {'data': news, 'item' : nbLoop, 'selected': postSelected} %}
  86.                          {% set nbLoop = nbLoop + 1 %}
  87.                      {%  endif  %}
  88.                  {% endfor %}
  89.              </ul>
  90.          </div>
  91.          <div class="sep"></div>
  92.      </div>
  93. {% endif %}