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

Open in your IDE?
  1. {% extends 'Frontend/layout.html.twig' %}
  2. {% block content %}
  3.   {# dump(category) #} {# dump(news) #}
  4.   <section id="news">
  5.     <!-- CATEGORY TABS -->
  6.     <article>
  7.       <div class="grid-container">
  8.         <div class="tabs-content" data-tabs-content="news-tabs">
  9.           <div class="tabs-panel is-active" id="all">
  10.             <aside class="listado">
  11.               <header>
  12.                 <h1>{{ category.translations[0].getName() }}</h1>
  13.               </header>
  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.                       <div class="cell small-12 medium-6 large-4">
  19.                         {% if new.getTranslations()[0].getTitle()|default %}
  20.                           {% set newsPath = path('new', { seoSlug: new.getTranslations()[0].getTitle()|make_url_phrase, id: new.getId() }) %}
  21.                         {% else %}
  22.                           {% set newsPath = '' %}
  23.                         {% endif %}
  24.                         {% if new.images[0] is defined %}
  25.                           {% set imgPath = IMG_PATH ~ new.images[0].section ~ '/' ~ new.images[0].itemId ~ '/resized/' ~ new.images[0].id ~ '_backendGallery.' ~ new.images[0].extension %}
  26.                         {% else %}
  27.                           {% set imgPath = '' %}
  28.                         {% endif %}
  29.                         <figure>
  30.                           <a href="{{ newsPath }}" title="{{ new.getTranslations()[0].getTitle() }}"><img src="{{ imgPath }}" alt="{{ new.getTranslations()[0].getTitle() }}" /></a>
  31.                         </figure>
  32.                         <div>
  33.                           <h3><a href="{{ newsPath }}" title="{{ new.getTranslations()[0].getTitle() }}">{{ new.getTranslations()[0].getTitle() }}</a></h3>
  34.                           {% for categ in new.getCategories() %}
  35.                             {# dump(categ) #}
  36.                             <a href="{{ path('newsByCateg', { seoSlugCategory: categ.getTranslations()[0].getName()|make_url_phrase, id: categ.getId() }) }}">{{ categ.getTranslations[0].getName() }}</a>
  37.                           {% endfor %}
  38.                           <span>{{ new.publicationDate|date('d/m/Y') }}</span>
  39.                         </div>
  40.                       </div>
  41.                     {% endif %}
  42.                   {% else %}
  43.                     <div class="cell small-12 medium-6 large-4">
  44.                       {% if new.getTranslations()[0].getTitle()|default %}
  45.                         {% set newsPath = path('new', { seoSlug: new.getTranslations()[0].getTitle()|make_url_phrase, id: new.getId() }) %}
  46.                       {% else %}
  47.                         {% set newsPath = '' %}
  48.                       {% endif %}
  49.                       {% if new.images[0] is defined %}
  50.                         {% set imgPath = IMG_PATH ~ new.images[0].section ~ '/' ~ new.images[0].itemId ~ '/resized/' ~ new.images[0].id ~ '_backendGallery.' ~ new.images[0].extension %}
  51.                       {% else %}
  52.                         {% set imgPath = '' %}
  53.                       {% endif %}
  54.                       <figure>
  55.                         <a href="{{ newsPath }}" title="{{ new.getTranslations()[0].getTitle() }}"><img src="{{ imgPath }}" alt="{{ new.getTranslations()[0].getTitle() }}" /></a>
  56.                       </figure>
  57.                       <div>
  58.                         <h3><a href="{{ newsPath }}" title="{{ new.getTranslations()[0].getTitle() }}">{{ new.getTranslations()[0].getTitle() }}</a></h3>
  59.                         {% for categ in new.getCategories() %}
  60.                           {# dump(categ) #}
  61.                           <a href="{{ path('newsByCateg', { seoSlugCategory: categ.getTranslations()[0].getName()|make_url_phrase, id: categ.getId() }) }}">{{ categ.getTranslations[0].getName() }}</a>
  62.                         {% endfor %}
  63.                         <span>{{ new.publicationDate|date('d/m/Y') }}</span>
  64.                       </div>
  65.                     </div>
  66.                   {% endif %}
  67.                 {% endfor %}
  68.               </div>
  69.             </aside>
  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('newsByCateg', { id: category.getId(), seoSlugCategory: category.getTranslations()[0].getName()|make_url_phrase, 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('newsByCateg', { id: category.getId(), seoSlugCategory: category.getTranslations()[0].getName()|make_url_phrase, 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('newsByCateg', { id: category.getId(), seoSlugCategory: category.getTranslations()[0].getName()|make_url_phrase, currentPage: i }) }}" aria-label="Page {{ i }}">{{ i }}</a>
  92.                       </li>
  93.                     {% endif %}
  94.                   {% endfor %}
  95.                   <li class="current">
  96.                     <a href="{{ path('newsByCateg', { id: category.getId(), seoSlugCategory: category.getTranslations()[0].getName()|make_url_phrase, 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('newsByCateg', { id: category.getId(), seoSlugCategory: category.getTranslations()[0].getName()|make_url_phrase, 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('newsByCateg', { id: category.getId(), seoSlugCategory: category.getTranslations()[0].getName()|make_url_phrase, currentPage: i }) }}" aria-label="Page {{ i }}">{{ i }}</a>
  113.                         </li>
  114.                       {% endif %}
  115.                     {% endfor %}
  116.                     <li class="pagination-next">
  117.                       <a href="{{ path('newsByCateg', { id: category.getId(), seoSlugCategory: category.getTranslations()[0].getName()|make_url_phrase, 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.           </div>
  124.         </div>
  125.       </div>
  126.     </article>
  127.   </section>
  128. {% endblock %}