templates/Default/counter.html.twig line 1

Open in your IDE?
  1. {% macro btn(link, expanded, icon, title, text, class) %}
  2. <a {% if link %} href='{{link}}' {% endif %}
  3.     class='{{ expanded ? "flex row middle vt-5-in hz-15-in border border-success success p upper" : "icon border small radius-50 iflex col middle" }} {{not link ? "disabled"}} {{class}}' title='{{title}}'>
  4.     <i class='icon contain min {{icon}}'></i>
  5.     {% if expanded and not isMobile() %}
  6.     <span> {{text}}</span>
  7.     {% endif %}
  8. </a>
  9. {% endmacro %}
  10. {% set expanded = expanded is defined and expanded ? true : false %}
  11. {% if offset is defined and count is defined %}
  12.     {% if count > 0 %}
  13.     <div class='flex row space counters-box middle'>
  14.         {% set route = app.request.attributes.get('_route') %}
  15.         {% set pageRoute = route~'-page' %}
  16.         {% set route = isRoute(pageRoute) ? pageRoute : route %}
  17.         {% if table_limit is not defined %}
  18.             {% set table_limit = 20 %}
  19.         {% endif %}
  20.         {% set limit = (offset+1)*table_limit %}
  21.         {% set currentPath = path(app.request.attributes.get('_route'),app.request.attributes.get('_route_params')) %}
  22.         {% if limit > count %} {% set limit = count %} {% endif %}
  23.         {% if not expanded %}
  24.         <div class='right-20 adapt p'>
  25.             <label>Résultats : </label>
  26.             <b class="">{{ (offset*table_limit)+1 }} - {{ limit }} sur {{ count }}</b>
  27.         </div>
  28.         {% endif %}
  29.         {% set link = false %}
  30.         {% if (offset*table_limit)+1 > 1 %}
  31.             {% if params is defined and params|length %}
  32.                 {% set params = params|merge({'offset':offset}) %}
  33.                 {% set link = url(route,params) %}
  34.             {% elseif cat is defined and cat %}
  35.                 {% set link = url(route,{'cat':cat,'offset':offset}) %}
  36.             {% else %}
  37.                 {% set link = url(route,{'offset':offset}) %}
  38.             {% endif %}
  39.         {% endif %}
  40.         {{ _self.btn(link, expanded, "arrow-left", "Page précédente", "Précédent", "adapt right-5") }}
  41.         {% if expanded %}
  42.         <b class='btn btn-success small trans'>{{ (offset*table_limit)+1 }} - {{ limit }} sur {{ count }}</b>
  43.         {% endif %}
  44.         {% set link = false %}
  45.         {% if limit < count %}
  46.             {% if params is defined and params|length %}
  47.                 {% set params = params|merge({'offset':offset+2}) %}
  48.                 {% set link = url(route,params) %}
  49.             {% elseif cat is defined and cat %}
  50.                 {% set link = url(route,{'cat':cat,'offset':offset+2}) %}
  51.             {% else %}
  52.                 {% set link = url(route,{'offset':offset+2}) %}
  53.             {% endif %}
  54.         {% endif %}
  55.         {{ _self.btn(link, expanded, "arrow-right", "Page suivante", "Suivant", "adapt left-5 reverse") }}
  56.     </div>
  57.     {% else %}
  58.     <label>Aucune donnée trouvée</label>
  59.     {% endif %}
  60. {% endif %}