Created
July 22, 2014 18:57
-
-
Save gondo/c24e196a8d3f159fb2ab to your computer and use it in GitHub Desktop.
KnpPaginatorBundle multiple paginators example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function listAction() | |
{ | |
$em = $this->getDoctrine()->getManager(); | |
$repository = $em->getRepository('ExampleBundle:Entity'); | |
$qb = $historyRepository->createQueryBuilder('EntityAlias'); | |
$knpPaginator = $this->get('knp_paginator'); | |
$paginationAAA = $knpPaginator->paginate( | |
$qb, | |
$this->get('request')->query->get('pageAAA', 1), // page number | |
10, // limit per page | |
array( | |
'pageParameterName' => 'pageAAA', | |
'sortFieldParameterName' => 'sortAAA', | |
'sortDirectionParameterName' => 'directionAAA', | |
) | |
); | |
$paginationBBB = $knpPaginator->paginate( | |
$qb, | |
$this->get('request')->query->get('pageBBB', 1), // page number | |
10, // limit per page | |
array( | |
'pageParameterName' => 'pageBBB', | |
'sortFieldParameterName' => 'sortBBB', | |
'sortDirectionParameterName' => 'directionBBB', | |
) | |
); | |
return array( | |
'paginationAAA' => $paginationAAA, | |
'paginationBBB' => $paginationBBB, | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if paginationAAA.getTotalItemCount > 0 %} | |
<table> | |
<thead> | |
<tr> | |
<th> | |
{{ knp_pagination_sortable(paginationAAA, 'Field', 'EntityAlias.field', {'defaultDirection' : 'desc'}) }} | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for rows in paginationAAA %} | |
<tr> | |
<td> | |
{{ row.field }} | |
</td> | |
{% endfor %} | |
</tbody> | |
</table> | |
{{ knp_pagination_render(paginationAAA) }} | |
{% else %} | |
No data. | |
{% endif %} | |
{% if paginationBBB.getTotalItemCount > 0 %} | |
<table> | |
<thead> | |
<tr> | |
<th> | |
{{ knp_pagination_sortable(paginationBBB, 'Field', 'EntityAlias.field', {'defaultDirection' : 'desc'}) }} | |
</th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for rows in paginationBBB %} | |
<tr> | |
<td> | |
{{ row.field }} | |
</td> | |
{% endfor %} | |
</tbody> | |
</table> | |
{{ knp_pagination_render(paginationBBB) }} | |
{% else %} | |
No data. | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why are you editing
sliding.html.twig
!? DONT touch that file at all! unless you know what are you doing, what clearly is not the case.use
{{ knp_pagination_render(paginationBBB) }}
, see my example