Pagination Issue |
Hi,
When using the Pager service to create manual pagination links, it doesn't seem to recognise the URL segment when you use setPath() with it. For example: PHP Code: $pager = \Config\Services::pager(); It creates the links all well, but when moving to page 2 or 3, the links still show as being on page 1 (i.e. not recognising the Segment in the url). My url is like: mysite.com/page/3 So I'm getting segment (2). I need to use setPath() so that the links include the "page" part in the URL as by default the homepage is just mysite.com. If I take a look at the Pager.php code, I can see that PHP Code: protected function ensureGroup(string $group, ?int $perPage = null) returns after setPath has been called. So when makeLinks() is called, the calculateCurrentPage() doesn't update the current page. If I comment out the // return; it starts to work perfectly. Not sure if this is a bug or if I'm just using the Pager service wrong.
This is a bug.
I sent a PR: https://github.com/codeigniter4/CodeIgniter4/pull/5803 Workround: PHP Code: $pager = \Config\Services::pager(); |
Welcome Guest, Not a member yet? Register Sign In |