Symfony2 PagerFantaBundle
Symfony2 PagerFantaBundle
我正在尝试使用 WhiteOctoberPagerfantaBundle
我确实跟着安装了。但是分页不起作用。
这是我的控制器:
$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
]);
这是树枝渲染图:
{{ pagerfanta(registers, 'twitter_bootstrap3') }}
这里有分页,但是当我喜欢上一个 link 时,它总是显示同一页(第一页)。
有什么想法吗?
好像是这样的:
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
]);
}
我正在尝试使用 WhiteOctoberPagerfantaBundle
我确实跟着安装了。但是分页不起作用。
这是我的控制器:
$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
]);
这是树枝渲染图:
{{ pagerfanta(registers, 'twitter_bootstrap3') }}
这里有分页,但是当我喜欢上一个 link 时,它总是显示同一页(第一页)。
有什么想法吗?
好像是这样的:
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
]);
}