templates/parts/pagination.html.twig line 1

Open in your IDE?
  1. {% set current_page = app.request.query.get('p') ?: 1 %}
  2. {% set current_route = app.request.attributes.get('_route') %}
  3. {% set current_params = app.request.query.all %}
  4. {% if last_page > 1 %}
  5.   <nav>
  6.     <ul class="pagination float-right">
  7.       {% if current_page > 1 %}
  8.         <li class="page-item">
  9.           <a class="page-link" href="{{ path(current_route, current_params|merge({p: current_page - 1})) }}" aria-label="Previous">
  10.             <span aria-hidden="true">&laquo;</span>
  11.             <span class="sr-only">Previous</span>
  12.           </a>
  13.         </li>
  14.       {% endif %}
  15.       {% for i in 1..last_page %}
  16.         <li class="page-item {% if i == current_page %}active{% endif %}">
  17.           <a class="page-link" href="{{ path(current_route, current_params|merge({p: i})) }}">{{ i }}</a>
  18.         </li>
  19.       {% endfor %}
  20.       {% if current_page < last_page %}
  21.         <li class="page-item">
  22.           <a class="page-link" href="{{ path(current_route, current_params|merge({p: current_page + 1})) }}" aria-label="Next">
  23.             <span aria-hidden="true">&raquo;</span>
  24.             <span class="sr-only">Next</span>
  25.           </a>
  26.         </li>
  27.       {% endif %}
  28.     </ul>
  29.   </nav>
  30. {% endif %}