Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] CI4 Pagination don't work fine
#2

I solved with this code:

Controller:
PHP Code:
<?php namespace App\Controllers;

use App\Models\TenantModel;

class TenantsCtrlComunica extends BaseController
{
    public function __construct(){
        $this->TenantModel = new TenantModel();
    }

    public function index()
    {
        $currPage = htmlentities($this->request->getGet('page'), ENT_QUOTES, 'UTF-8');            
        $data 
= [
            'currPage'          => (isset($currPage) && $currPage!='') ? $currPage : 0,
            'countAll'          => $this->TenantModel->countAll(),
            'recordsForPage'    => 3,
            'tenants'           => $this->TenantModel->paginate(3),
            'pager'             => $this->TenantModel->pager,
        ];      
        return view
('tenants_list', $data);
    }


Page :

PHP Code:
<?= $pager->makeLinks($currPage$recordsForPage$countAll?>
Reply


Messages In This Thread
RE: CI4 Pagination don't work fine - by rodrigo76 - 06-24-2020, 01:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB