I need some advice with pagination in an application I migrated from 4.x to 5.x. I am getting the error message: “You must set a pagination instance using setPaginated()
first” when my template file, index.php loads. The code snippet below is from my index.php file and is where the error occurs.
<div class="paginator text-center">
<ul class="pagination">
<?= $this->Paginator->first('<< ' . __('First')) ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->last(__('Last') . ' >>') ?>
</ul>
<p><?= $this->Paginator->counter() ?></p>
</div>
In the controller, my code is as follows:
$beacons = $this->Beacons->find(‘all’, contain: [‘Triggers’, ‘Floors.Buildings.Sites’])->where([‘site_id’ => $site_id]);
$settings = [‘limit’ => 10, ‘scope’ => ‘beacons’, ‘order’ => [‘Beacons.name’ => ‘ASC’]];
$this->set(‘_serialize’, $this->paginate(‘beacons’, $settings));
$this->set(compact(‘beacons’));
All Im doing is showing a list of beacons(a beacon is a location for a wayfinder app), and trying to limit the view to 10 per page.
Has anyone ever had a similar issue when migrating to 5.x? If so, can you please share any suggestions/solutions?
Thanks in advance!