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

(This post was last modified: 06-24-2020, 01:14 AM by rodrigo76.)

Hi to all,

i use CI 4.0.3 and I read CI4 documentation : https://codeigniter.com/user_guide/libra...ation.html

This is my controller:

PHP Code:
<?php namespace App\Controllers;

use App\Models\TenantModel;

class TenantsCtrlComunica extends BaseController
{
    public function __construct(){
        $pager = \Config\Services::pager();
        $this->TenantModel = new TenantModel();
    }
    public function index()
    {
        $data = [
            'tenants'   => $this->TenantModel->paginate(3),
            'pager'     => $this->TenantModel->pager,
        ];
        echo view('tenants_list', $data);
    }


This is my model :

PHP Code:
<?php namespace App\Models;

use 
CodeIgniter\Model;

class 
TenantModel extends Model
{
    protected $table      'tenant_table';
    protected $primaryKey 'id_tenant';
    protected $returnType     'object';
    protected $useSoftDeletes false;
    protected $allowedFields = ['name''enabled''keys''description'];
    protected $useTimestamps true;
    protected $createdField  null;
    protected $updatedField  null;
    protected $deletedField  null;



In my php Page I wrote this:
PHP Code:
<?= $pager->links()?>

BUT, in my web page I watch only an "1" (I attached an image); this is the HTML rendered by previous code:

PHP Code:
...
    <
ul class="pagination">
        <
li class="active"> <a href="http://comunica.local:888/public/tenants?page=1"</a> </li>
    </
ul>
... 


In my database I have 12 records and if I play with pagination's params I see different records.

Where I am wrong? Huh Huh

Many thanks for your help!

Rodrigo
Reply


Messages In This Thread
[SOLVED] CI4 Pagination don't work fine - by rodrigo76 - 06-23-2020, 10:05 AM
RE: CI4 Pagination don't work fine - by rodrigo76 - 06-24-2020, 01:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB