templates/Frontend/news/news_paginated.html.twig line 1

Open in your IDE?
  1. {% extends 'Frontend/layout.html.twig' %}
  2. {% block content %}
  3.   {# dump(news) #}
  4.   <section id="news">
  5.     <article>
  6.       <div class="grid-container">
  7.         <div class="tabs-content" data-tabs-content="news-tabs">
  8.           <div class="tabs-panel is-active" id="all">
  9.             <aside class="listado">
  10.               <header>
  11.                 <h1>{% trans %}Hemeroteca{% endtrans %}</h1>
  12.               </header>
  13.               <div>{{ render(controller('App\\Controller\\Frontend\\SearchController::drawForm')) }}</div>
  14.               <div class="grid-x grid-margin-x grid-margin-y">
  15.                 {% for new in news %}
  16.                   {% if new.id == news_for_china_only %}
  17.                     {% if fromChina is not empty %}
  18.                       {# dump(new) #}
  19.                       <div class="cell small-12 medium-6 large-4">
  20.                         {% if new.getTranslations()[0].getTitle()|default %}
  21.                           {% set newsPath = path('new', { seoSlug: new.translations[0].getTitle()|make_url_phrase, id: new.getId() }) %}
  22.                         {% else %}
  23.                           {% set newsPath = '' %}
  24.                         {% endif %}
  25.                         {% if new.images[0] is defined %}
  26.                           {% set imgPath = IMG_PATH ~ new.images[0].section ~ '/' ~ new.images[0].itemId ~ '/resized/' ~ new.images[0].id ~ '_backendGallery.' ~ new.images[0].extension %}
  27.                         {% else %}
  28.                           {% set imgPath = '' %}
  29.                         {% endif %}
  30.                         <figure>
  31.                           <a href="{{ newsPath }}" title="{{ new.getTitle() }}"><img src="{{ imgPath }}" alt="{{ new.getTitle() }}" /></a>
  32.                         </figure>
  33.                         <div>
  34.                           <h3><a href="{{ newsPath }}" title="{{ new.translations[0].getTitle() }}">{{ new.translations[0].getTitle() }}</a></h3>
  35.                           {% for categ in new.getCategories() %}
  36.                             {# dump(categ) #}
  37.                             <a href="{{ path('newsByCateg', { seoSlugCategory: categ.getTranslations()[0].getName()|make_url_phrase, id: categ.getId() }) }}">{{ categ.translations[0].getName() }}</a>
  38.                           {% endfor %}
  39.                           <span>{{ new.publicationDate|date('d/m/Y') }}</span>
  40.                         </div>
  41.                       </div>
  42.                     {% endif %}
  43.                   {% else %}
  44.                     <div class="cell small-12 medium-6 large-4">
  45.                       {% if new.getTranslations()[0].getTitle()|default %}
  46.                         {% set newsPath = path('new', { seoSlug: new.translations[0].getTitle()|make_url_phrase, id: new.getId() }) %}
  47.                       {% else %}
  48.                         {% set newsPath = '' %}
  49.                       {% endif %}
  50.                       {% if new.images[0] is defined %}
  51.                         {% set imgPath = IMG_PATH ~ new.images[0].section ~ '/' ~ new.images[0].itemId ~ '/resized/' ~ new.images[0].id ~ '_backendGallery.' ~ new.images[0].extension %}
  52.                       {% else %}
  53.                         {% set imgPath = '' %}
  54.                       {% endif %}
  55.                       <figure>
  56.                         <a href="{{ newsPath }}" title="{{ new.getTitle() }}"><img src="{{ imgPath }}" alt="{{ new.getTitle() }}" /></a>
  57.                       </figure>
  58.                       <div>
  59.                         <h3><a href="{{ newsPath }}" title="{{ new.translations[0].getTitle() }}">{{ new.translations[0].getTitle() }}</a></h3>
  60.                         {% for categ in new.getCategories() %}
  61.                           {# dump(categ) #}
  62.                           <a href="{{ path('newsByCateg', { seoSlugCategory: categ.getTranslations()[0].getName()|make_url_phrase, id: categ.getId() }) }}">{{ categ.translations[0].getName() }}</a>
  63.                         {% endfor %}
  64.                         <span>{{ new.publicationDate|date('d/m/Y') }}</span>
  65.                       </div>
  66.                     </div>
  67.                   {% endif %}
  68.                 {% endfor %}
  69.               </div>
  70.               {% if totalPages > 1 %}
  71.                 {% set extremePagesLimit = 1 %} {# El nº de primeras y últimas páginas a mostrar #}
  72.                 {% set nearbyPagesLimit = 3 %} {# El nº de páginas que se muestran desde la página actual #}
  73.                 <nav aria-label="Pagination">
  74.                   <ul class="pagination">
  75.                     <li>
  76.                       <a href="{{ path('newsPaginated', { currentPage: currentPage - 1 }) }}" aria-label="Previous page"><img src="{{ asset('assets/images/icon/arrow-left.svg') }}" title="{% trans %}Anterior{% endtrans %}" /></a>
  77.                     </li>
  78.                     {% for i in 1..extremePagesLimit %}
  79.                       {% if i < currentPage - nearbyPagesLimit %}
  80.                         <li>
  81.                           <a href="{{ path('newsPaginated', { currentPage: i }) }}" aria-label="Page {{ i }}">{{ i }}</a>
  82.                         </li>
  83.                       {% endif %}
  84.                     {% endfor %}
  85.                     {% if extremePagesLimit + 1 < currentPage - nearbyPagesLimit %}
  86.                       <li class="ellipsis" aria-hidden="true"></li>
  87.                     {% endif %}
  88.                     {% for i in range(currentPage - nearbyPagesLimit, currentPage - 1) %}
  89.                       {% if i > 0 %}
  90.                         <li>
  91.                           <a href="{{ path('newsPaginated', { currentPage: i }) }}" aria-label="Page {{ i }}">{{ i }}</a>
  92.                         </li>
  93.                       {% endif %}
  94.                     {% endfor %}
  95.                     <li class="current">
  96.                       <a href="{{ path('newsPaginated', { currentPage: currentPage }) }}" aria-label="Page {{ currentPage }}">{{ currentPage }}</a>
  97.                     </li>
  98.                     {% if currentPage < totalPages %}
  99.                       {% for i in range(currentPage + 1, currentPage + nearbyPagesLimit) %}
  100.                         {% if i <= totalPages %}
  101.                           <li>
  102.                             <a href="{{ path('newsPaginated', { currentPage: i }) }}">{{ i }}</a>
  103.                           </li>
  104.                         {% endif %}
  105.                       {% endfor %}
  106.                       {% if totalPages - extremePagesLimit > currentPage + nearbyPagesLimit %}
  107.                         <li class="ellipsis" aria-hidden="true"></li>
  108.                       {% endif %}
  109.                       {% for i in range(totalPages - extremePagesLimit + 1, totalPages) %}
  110.                         {% if i > currentPage + nearbyPagesLimit %}
  111.                           <li>
  112.                             <a href="{{ path('newsPaginated', { currentPage: i }) }}" aria-label="Page {{ i }}">{{ i }}</a>
  113.                           </li>
  114.                         {% endif %}
  115.                       {% endfor %}
  116.                       <li class="pagination-next">
  117.                         <a href="{{ path('newsPaginated', { currentPage: currentPage + 1 <= totalPages ? currentPage + 1 : currentPage }) }}" aria-label="Next page"><img src="{{ asset('assets/images/icon/arrow.svg') }}" title="{% trans %}Siguiente{% endtrans %}" /></a>
  118.                       </li>
  119.                     {% endif %}
  120.                   </ul>
  121.                 </nav>
  122.               {% endif %}
  123.             </aside>
  124.           </div>
  125.         </div>
  126.       </div>
  127.     </article>
  128.   </section>
  129. {% endblock %}