KnpLabs / KnpPaginatorBundle

SEO friendly Symfony paginator to sort and paginate
http://knplabs.com/en/blog/knp-paginator-reborn
MIT License
1.76k stars 342 forks source link

How to remove page query parameter from first page? #804

Open scion4581 opened 1 month ago

scion4581 commented 1 month ago

|---------------- | ------ | Bundle version | 6.4.0 | Symfony version | 6.4.10 | PHP version | 8.2.2

Support Question

Hi! I can't understand how to remove page query param automatically when it equal 1

For example, https://example.com/posts and https://example.com/posts?page=1 same pages and I need to remove the parameter page making the first page always without page param

Maybe I miss some configuration for this case?

Thanks

garak commented 1 month ago

That is not implemented currently. Here's an idea for a possible improvement: we could add a new Twig function (or filter) taking the page number as an argument and returning the same page number, unless the number is 1 (if so, null should be returned). Then we can use such new function/filter to build the links in our templates.

Probably this would require a new option (and so being disabled by default), to keep BC