KnpLabs/KnpPaginatorBundle — pull request #160 by n3ur0n (2013-03-11 13:46:42+00:00)
Title: Custom url for pages based on routes

# PR for issue #158
An alternative to query params

## Usage

### config.yml

```yml
knp_paginator:
template:
pagination: KnpPaginatorBundle:Pagination:twitter_bootstrap_pagination_route.html.twig
```

### Controller

```php
/**
* @Route("/", name="acme_demo")
* @Route("/page/{page}/", name="acme_demo_paginator")
* @Template()
*/
public function indexAction($page = 1)
{
$em = $this->get('doctrine.orm.entity_manager');
$dql = "SELECT a FROM AcmeDemoBundle:Article a";
$query = $em->createQuery($dql);
$pagination = $paginator->paginate(
$query,
$page /*page number*/,
10/*limit per page*/
);

return array(
'pagination' => $pagination
);
}
```

### View

```jinja

{{ knp_pagination_render(pagination, null, {}, {'firstPageRoute': 'acme_demo', 'otherPagesRoute': 'acme_demo_paginator'}) }}

```

**Note:** If you want to set routes in controller, there is an alternative:
```php
$pagintion->setFirstPageRoute('acme_demo');
$pagintion->setOtherPagesRoute('cme_demo_paginator');
```