I'm try to use the WhiteOctoberPagerfantaBundle
I did follow the install. But the pagination does not work.
Here is my controller:
$client = $this->getUser()->getsite()->getClient();
$registersQB = $em->getRepository('AppBundle:Activity\Register')->findAllByClient($client);
$pagerfanta = new Pagerfanta(new DoctrineORMAdapter($registersQB));
$pagerfanta->setMaxPerPage(4);
$registers = $pagerfanta;
$tpl = 'AppBundle:Activity/Register:index.html.twig';
return $this->render($tpl, [
'registers' => $registers
]);
And here is the twig rendering:
{{ pagerfanta(registers, 'twitter_bootstrap3') }}
The pagination is here, but when i'm liking in the previous link, it always display the same page (page one).
Any idea?
It seems to work like that:
public function indexAction(Request $request)
{
$params['page'] = (int)$request->query->get('page', 1);
$params['limit'] = (int)$request->query->get('limit', 4);
$client = $this->getUser()->getsite()->getClient();
$registersQB = $em->getRepository('AppBundle:Activity\Register')->findAllByClient($client);
$pagerfanta = new Pagerfanta(new DoctrineORMAdapter($registersQB));
$pagerfanta->setMaxPerPage($params['limit'])->setCurrentPage($params['page']);
$registers = $pagerfanta;
$tpl = 'AppBundle:Activity/Register:index.html.twig';
return $this->render($tpl, [
'registers' => $registers,
'client' => $client
]);
}