-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pageParameterName not supported #815
Comments
I just tried and see that the expected behaviour is what I get. |
your new knp_pagination_query function no longer supports "pageParameterName" |
The link is generated correctly for me, but the page is not advancing indeed. |
Yes i have copied Older version |
Same problem here: |
Could you try this patch on your vendor knp-paginator-bundle dir? --- a/src/Twig/Extension/PaginationRuntime.php
+++ b/src/Twig/Extension/PaginationRuntime.php
@@ -113,16 +113,18 @@ final class PaginationRuntime implements RuntimeExtensionInterface
* @param int $page
* @return array<string, mixed>
*/
- public function getQueryParams(array $query, int $page): array
+ public function getQueryParams(array $query, int $page, ?SlidingPaginationInterface $pagination = null): array
{
+ $pageName = $pagination?->getPaginatorOption('page_name') ?? $this->pageName;
+
if ($page === 1 && $this->skipFirstPageLink) {
- if (isset($query[$this->pageName])) {
- unset($query[$this->pageName]);
+ if (isset($query[$pageName])) {
+ unset($query[$pageName]);
}
return $query;
}
- return array_merge($query, [$this->pageName => $page]);
+ return array_merge($query, [$pageName => $page]);
}
} if you confirm it works, I'll release a patch version later today |
Hello, It work for me : `public function getQueryParams(array $query, int $page, ?string $pageParameterName = null): array
on Twig function add pageParameterName |
The variable is the pagination object passed to your template |
The solution of Vertica works indeed
And in all places (all templates) change |
I'm sure it works, but it would force use to extract the pageParameterName to be passed everywhere. Moreover, it's not future-proof: if one day we find in the need of another option, we would be forced to add a new argument. |
@garak the issue with your proposed solution is that in the templates of the bundle we have no access to the For example, using the Bootstrap 5 template, <li class="page-item">
<a class="page-link" href="{{ path(route, knp_pagination_query(query, pageCount - 1)) }}">{{ pageCount - 1 }}</a>
</li> And the parameters which are passed to the template are generated from the call to twig function I understand your concern about needing to pass If you're sure that's the way that you'd like to approach things, I can create a PR (because this bug is causing problems with an upstream library I'm trying to implement)? |
PS I would also add, that using <li class="page-item">
<a class="page-link" rel="prev" href="{{ path(route, query|merge({(pageParameterName): previous})) }}">« {{ 'label_previous'|trans({}, 'KnpPaginatorBundle') }}</a>
</li> |
I see your point. Can you propose a PR? |
Bug Report
Summary
Parameter "pageParameterName" is not supported in links
Current behavior
Exemple with bootstrap 4: link is /suivi?page=2
How to reproduce
$paginator->paginate($repo->relanceDemande(),$request->query->getInt('pageRelanceDemande',1),50,['pageParameterName'=>'pageRelanceDemande']);
Expected behavior
link : /suivi?pageRelanceDemande=2
The text was updated successfully, but these errors were encountered: