# Paginator Error

**URL:** <https://discourse.cakephp.org/t/paginator-error/12806>\
**Category:** Uncategorized\
**Created:** [February 17, 2026, 4:58pm UTC](https://discourse.cakephp.org/t/paginator-error/12806 "2026-02-17T16:58:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klaus](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/klaus/32/269_2.png) [@Klaus](https://discourse.cakephp.org/u/Klaus)\
**Post date:** [February 17, 2026, 4:58pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/1 "2026-02-17T16:58:32Z")

</div>

Hello, I am moving to cake 5.1 and receive Paginator Error in the template inthe header tags.  
My Controller function:

```php
public function index($id = null) {
    $query = $this->News->find();

    $news = $this->paginate($query, [
        'scope' => 'news'
    ]);
    $this->set(compact('news'));
    $this->render('/Homepage/News/index');
}

```

Error: TypeError: Cake\View\View::get(): Argument #1 ($var) must be of type string, int given  
called in PaginatorHelper.php on line 142  
Template

```php
<?php
/**
 * @var \\App\\View\\AppView $this
 * @var iterable<\\App\\Model\\Entity\\Article> $articles
 */
$yesno = $this->get('appYesNo');
$appnews = $this->get('appNews');
?>
<?= $this->Element('navigation', ['navi' => $prodItem]); ?>
<div class="news index content">
    <?= $this->Html->link(__('Neue Neuigkeit'), ['action' => 'add'], ['class' => 'button float-right']) ?>
    <h3><?= __('Neuigkeiten') ?></h3>
    <div class="table-responsive">
        <table>
            <thead>
                <tr>
                    <th width="40"><?= $this->Paginator->sort('id') ?></th>
                    <th width="300"><?= $this->Paginator->sort('title') ?></th>
                    <th><?= $this->Paginator->sort('type') ?></th>
                    <th><?= $this->Paginator->sort('folder') ?></th>
                    <th><?= $this->Paginator->sort('active') ?></th>
                    <th><?= $this->Paginator->sort('login') ?></th>
                    <th width="200" class="actions"><?= __('Actions') ?></th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($news as $news): ?>
                    <tr>
  <td><?= h($news->title) ?></td>
                    <td>
                        <?php
                        echo $appnews[$news->type];
                        ?>
                    </td>
                    <td><?= h($news->folder) ?></td>
                    <td>
                        <?php
                        echo $yesno[$news->active];
                        ?>
                    </td>
                    <td>
                        <?php
                        echo $yesno[$news->login];
                        ?>
                    </td>
                    <?= $this->Element('viewArticleAction', array('recCon' => 'News', 'action' => 'singleNews', 'recId' => $news->id, 'parentId' => $news->id)); ?>   
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
    <div class="paginator">
        <ul class="pagination">
            <?= $this->Paginator->first('<< ' . __('first')) ?>
            <?= $this->Paginator->prev('< ' . __('previous')) ?>
            <?= $this->Paginator->numbers() ?>
            <?= $this->Paginator->next(__('next') . ' >') ?>
            <?= $this->Paginator->last(__('last') . ' >>') ?>
        </ul>
        <p><?= $this->Paginator->counter(__('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')) ?></p>
    </div>
</div>

```

Whats the problem? Kid regards Klaus

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [February 17, 2026, 7:03pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/2 "2026-02-17T19:03:05Z")

</div>

@Klaus first of all - please use the “Preformatted text” Feature in this Forum so your code actually gets pasted in properly. I manually cleaned it up for now.

But your “problem” here is this line at the top:

```php
$appnews = $this->get('appNews');

```

You don’t need to retrieve data inside your templates. Whenever you set a variable inside the controller like so

```php
$this->set(compact('news'));

```

you automatically have access to it via `$news`

Also you can look at all your accesible variables via Debug Kit “Variables” Panel or just add a simple

```auto
pr($this->viewVars);

```

in your template (and make sure your Debug Mode is active) to see what your current scope of variables has to offer.

---

<div class="post-metadata">

**Author:** ![thomasg](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@thomasg](https://discourse.cakephp.org/u/thomasg)\
**Post date:** [March 11, 2026, 2:25pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/3 "2026-03-11T14:25:28Z")

</div>

You may write foreach($news as $item):

---

<div class="post-metadata">

**Author:** ![Klaus](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/klaus/32/269_2.png) [@Klaus](https://discourse.cakephp.org/u/Klaus)\
**Post date:** [March 17, 2026, 3:30pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/4 "2026-03-17T15:30:32Z")

</div>

Thanks, but looks to me as an bug. I have baked all controller, model and templates and without any changes from my side the error occures. It is cake 5.2.10. A short example:  
public function userMembers($id = null) {

```
    $names = $this->request->getParam('pass');

    $query = $this->Users->find()

            ->where(\['member LIKE' => '%' . $names\[0\] . '%'\])

            ->order(\['username' => 'ASC'\]);

           

     $users = $this->paginate($query);        

    $this->set(compact('users'));

    $this->set('group', $names);

}
        <thead>

            <tr>

                <th><?= $this->Paginator->sort('Users.id') ?></th>

                <th><?= $this->Paginator->sort('Users.username') ?></th>

                <th><?= $this->Paginator->sort('Users.phone') ?></th>

                <th><?= $this->Paginator->sort('Users.email') ?></th>

                <th><?= $this->Paginator->sort('Users.city') ?></th>

            </tr>

        </thead>

```

without the header, the template runs correct. Any suggestion?? Kinde regards klaus

---

<div class="post-metadata">

**Author:** ![dereuromark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dereuromark/32/37_2.png) [@dereuromark](https://discourse.cakephp.org/u/dereuromark)\
**Post date:** [March 17, 2026, 5:09pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/5 "2026-03-17T17:09:37Z")

</div>

Yes, that’s a bug in the code generation in case the plural/singular inflection leads to the same word.  
A rare case, but sure an issue for “news”.  
[Fix singular/plural variable collision in baked templates by dereuromark · Pull Request #1075 · cakephp/bake · GitHub](https://github.com/cakephp/bake/pull/1075) will fix it.

---

<div class="post-metadata">

**Author:** ![Klaus](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/klaus/32/269_2.png) [@Klaus](https://discourse.cakephp.org/u/Klaus)\
**Post date:** [March 17, 2026, 5:49pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/6 "2026-03-17T17:49:32Z")

</div>

Thanks for a quick reply, is there an advice to fix it manually in the code?  
I would not like to bake all templates from scratch.

Regards Klaus

---

<div class="post-metadata">

**Author:** ![dereuromark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dereuromark/32/37_2.png) [@dereuromark](https://discourse.cakephp.org/u/dereuromark)\
**Post date:** [March 17, 2026, 7:05pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/7 "2026-03-17T19:05:06Z")

</div>

It is only 1 place (index.php), with IDE this is 1 change to do. You could try custom bake templates and stuff, but this would probably be more work for until 1-2 days when the fix is released.

---

<div class="post-metadata">

**Author:** ![Klaus](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/klaus/32/269_2.png) [@Klaus](https://discourse.cakephp.org/u/Klaus)\
**Post date:** [March 19, 2026, 4:37pm UTC](https://discourse.cakephp.org/t/paginator-error/12806/8 "2026-03-19T16:37:58Z")

</div>

Hi Mark, because I am not used with this, I want to know, how I get the information about the fix and what my next step would be. Installation from scatch, baking all templates ???

Could you please give a short advice? Regards Klaus

---

<div class="post-metadata">

**Author:** ![dereuromark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dereuromark/32/37_2.png) [@dereuromark](https://discourse.cakephp.org/u/dereuromark)\
**Post date:** [March 20, 2026, 1:05am UTC](https://discourse.cakephp.org/t/paginator-error/12806/9 "2026-03-20T01:05:52Z")

</div>

If you are familiar with composer, you can also check out the dev branch in the meantime:  
composer require statement: dev-fix-singular-plural-var-collision

This way you can use the fix already without it being released.

---

<div class="post-metadata">

**Author:** ![dereuromark](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dereuromark/32/37_2.png) [@dereuromark](https://discourse.cakephp.org/u/dereuromark)\
**Post date:** [March 22, 2026, 11:32am UTC](https://discourse.cakephp.org/t/paginator-error/12806/10 "2026-03-22T11:32:21Z")

</div>

[Release Bake 3.6.3 · cakephp/bake · GitHub](https://github.com/cakephp/bake/releases/tag/3.6.3) Released the fix.
