# Cakephp 4 paginator with multiple models

**URL:** <https://discourse.cakephp.org/t/cakephp-4-paginator-with-multiple-models/9464>\
**Category:** Need Help\
**Tags:** help\
**Created:** [June 28, 2021, 6:49pm UTC](https://discourse.cakephp.org/t/cakephp-4-paginator-with-multiple-models/9464 "2021-06-28T18:49:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlzGamer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/alzgamer/32/2144_2.png) [@AlzGamer](https://discourse.cakephp.org/u/AlzGamer)\
**Post date:** [June 28, 2021, 6:49pm UTC](https://discourse.cakephp.org/t/cakephp-4-paginator-with-multiple-models/9464/1 "2021-06-28T18:49:02Z")

</div>

Hello.  
I have a problem with paginator on cakephp 4.2.7. Paginator remove custom pass params of url, when using a few models.  
Example:

```auto
https://domain.name/controller/action/pass1/

```

Link for sorting or paginate the link looks like this:

```auto
https://domain.name/controller/action?modelName[sort]=column&modelName[direction]=asc

```

The problem appeared after updating from 3.6 to 4.2

How to fix it?  
Thanks.

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [June 29, 2021, 4:28pm UTC](https://discourse.cakephp.org/t/cakephp-4-paginator-with-multiple-models/9464/2 "2021-06-29T16:28:51Z")

</div>

I assume you’re seeing this problem in links that are generated by the PaginatorHelper…

I don’t remember all the details of this fix, but I did find some code where I corrected for it. I even left a comment for my future self! This may give you some clues to follow:

```php
    /**
     * This tweak fixes a problem where the 'pass' values in a
     * request params package won't be included in the output url.
     * The pass values must be moved up out of the pass node.
     */
    $pass = $params['pass'] ?? [];
    $url = $params + $pass;

    echo '<ul class="paging-controls">';
    echo $this->Paginator->first('<< ', ['url' => $url]);
    echo $this->Paginator->prev('< ', ['url' => $url]);
    echo $this->Paginator->numbers(['url' => $url]);
    echo $this->Paginator->next('>', ['url' => $url]);
    echo $this->Paginator->last(' >>', ['url' => $url]);

```

---

<div class="post-metadata">

**Author:** ![AlzGamer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/alzgamer/32/2144_2.png) [@AlzGamer](https://discourse.cakephp.org/u/AlzGamer)\
**Post date:** [July 1, 2021, 10:08am UTC](https://discourse.cakephp.org/t/cakephp-4-paginator-with-multiple-models/9464/3 "2021-07-01T10:08:59Z")

</div>

> [@dreamingmind](#):
>
> links that are generated by the PaginatorHelper

Yes, problem wiht links that are generated by the PaginatorHelper.  
And i’we fixed problem with paginations links like a your example, but I had to consider about model , because I use [Paginating Multiple Results](https://book.cakephp.org/4/en/views/helpers/paginator.html#paginating-multiple-results) . But sorting of paginator - remove pass of url. If use url need to conside other query parametrs . I can make element and use it with custom url, but I hope that this problem can be fix, because it was work in cakephp 3.\*
