-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Basically i've set up the pager to work on segments.
but the pages actually retain queryString from uri if i go to
https://example.com/blog/2?page=2
When the PagerRenderer kicks in it should remove ?page=2 from the query string when recreating the pager links
https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Pager/PagerRenderer.php#L265
I have changed this function like this
public function links(): array
{
$links = [];
$uri = clone $this->uri;
for ($i = $this->first; $i <= $this->last; $i++) {
$uri = $this->segment === 0 ? $uri->addQuery($this->pageSelector, $i) : $uri->setSegment($this->segment, $i);
$links[] = [
'uri' => URI::createURIString(
$uri->getScheme(),
$uri->getAuthority(),
$uri->getPath(),
$uri->getQuery(['except' => ['page']]), // actualy it should only retain queryString that is not page
$uri->getFragment()
),
'title' => $i,
'active' => ($i === $this->current),
];
}
return $links;
}But this implementation approach should only work when pager is set up on segments instead of query string.
This works for me for now but when I switch back to using the pager as before, for sure with this approach will not work.
My Feature request is to add this option to the Pager Config
Metadata
Metadata
Assignees
Labels
No labels