1

I have a pagination with Pagerfanta. I want to limit page numbers to 5, since on mobile version pagination is too large. I am using default view 'twitter_bootstrap_translated'.

{% if articles.haveToPaginate %}
   <div class="pagination-class">
      {{ pagerfanta(articles, 'twitter_bootstrap_translated', {routeName: 'search_result_paginated', routeParams: app.request.query.all}) }}
   </div>
{% endif %}

How I can limit the page numbers/links?

Currently: < Prev | 1 | 2 | 3 | 4 | 5 | 6 | 7 | ... 101 | Next >

I need pagination like this: Currently: < Prev | 1 | 2 | 3 | ... 101 | Next >

Milos Ilic
  • 23
  • 4

1 Answers1

0

Please have a look might be useful:

<?php

use Pagerfanta\View\TwitterBootstrapView;

$view = new TwitterBootstrapView();
$options = array('proximity' => 3);
$html = $view->render($pagerfanta, $routeGenerator, $options);

Options (default):
       proximity (3)
       prev_message (← Previous)
       prev_disabled_href ()
       next_message (Next →)
       next_disabled_href ()
       dots_message (…)
       dots_href ()
       css_container_class (pagination)
       css_prev_class (prev)
       css_next_class (next)
       css_disabled_class (disabled)
       css_dots_class (disabled)
       css_active_class (active)

Mitesh Vasava
  • 707
  • 6
  • 13
  • If I set proximity to 1, I am getting less numbers but these dots are taking some space again ;) ``` {% if articles.haveToPaginate %}
    {{ pagerfanta(articles, 'twitter_bootstrap_translated', {routeName: 'search_result_paginated', routeParams: app.request.query.all, 'proximity': '1'}) }}
    {% endif %} ``` Thanks for help
    – Milos Ilic May 06 '19 at 13:41
  • You make hide dots using css – Mitesh Vasava May 06 '19 at 14:14