(07-05-2021, 02:33 AM)dazzafact Wrote: Hello, i try to get started with the Pager.
(for example my Listsite on Page 6)
$pager = \Config\Services::pager();
$pager->setPath('/vereine/p');
$data['pager']=$pager->makeLinks(6, 24, 12345,'bootstrap',4);
The Html will create fine, except for the right "active" Page! It always active on page "1"
If i now remove the Segments (in the arguments), the active Num seems to works, but without giving me a right Path:
$pager->makeLinks(6, 24, 12345,'bootstrap');
I tried different nums in Segment, nothing work.
But my Solution was then very easy, i just edited one line in the System-Library of Pager.php wich was overwrite my "currentPage"
//Old
$page = $this->groups[$group]['currentPage']; // Line 187
//changed to
if(!($page>$this->groups[$group]['currentPage'])){
$page = $this->groups[$group]['currentPage'];
}
I dont know why it always overwrites my currentPage, if i set the $segments-arguments.
Now everything works fine for me with this "System changes" 
I may have had something like this a while back... and don't recall get any responses to my questions on the forum (so I'm not sure if I was the only one experiencing it).
Like I say, it was a while ago, so don't hold me to it, but I think the way I fixed this problem was to also edit the framework code.
Try modifying paginate() in /system/BaseModel.php in v4.1.3:
From:
$pager = Services::pager(null, null, false);
To:
$pager = Services::pager(null, null, true);
Or in previous versions (v4.0.x) modify paginate() in Model.php:
From:
$pager = \Config\Services::pager(null, null, false);
To:
$pager = \Config\Services::pager(null, null, true);
... which, if I recall, will make the pager reference the shared copy (which is where the page number is stored)... or something like that... I'd had a few glasses of wine at the time, so my recollection is a bit hazy.