whiteoctober / Pagerfanta

Pagination for PHP.
Other
1.59k stars 2 forks source link

Pagerfanta does not switch pages #257

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hello everyone. I'm using Pagerfanta with Symfony 4. Data on the page is displayed, the number of pages is also displayed. but when you try to go to another page, the link changes, but the page does not switch. Here is my controller default

And here is repository

default What am I doing wrong?

sampart commented 5 years ago

Hi @powerlimit.

By default, thepagerfanta adds a querystring (get) parameter called page with the number of the page you request. You'll need to make use of this in your controller.

For example:

if ($request->get('page') !== null) {
    $pagerfanta->setCurrentPage($request->get('page'));
}

You'll need to add an argument Request $request to your controller method as well to make the request available.

You've reminded me that documentation about usage like this needs improving, so I'll try and get a PR in for that later (if I remember rightly, I actually hit this problem when I first used Pagerfanta myself!)

ghost commented 5 years ago

@sampart , merry me!! it worked. Thank you very much

sampart commented 5 years ago

Glad to hear it, @powerlimit! Thanks