• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create pagination on CI4


'test' => $model->orderBy('id', 'DESC')->paginate(2, 'res'),

Thank you! Amazing how a simple detail changes everything. As soon as I saw your post the solution to my problem came complete at once.
In addition to the model that collects the table data, I created another one where the table fields are selected according to the search argument.

PHP Code:
<?php namespace App\Controllers;
    use CodeIgniter\Controller;
    use App\Models\AlbunsListModel;

    class Albumlists extends Controller {    
public function genre1()
= new AlbunsListModel();
        $genresModel = new AlbunsGenresModel();

        $style $genresModel->getGenre1();
= [
            'genre1' => $listModel->orderBy('player_id''ano''title''asc')
            'pager' => $listModel->pager,
            'total' => $genresModel->numGenre1(),
            'genre' => $genresModel->getGenre1()

        $header = array ( 
'icon' => 'favicon'
'css' => 'albumlists',
'title' => $genre'records. - wdeda',
'action' => '/ci4/search/allmedia/',
'placeholder' => 'Pesquisar'

//and so on... 

 There is still a pending detail. In the page header I inform the number of items listed in relation to the total pages:
1->20 of 1426 titles, for example, but I need the segment number instead of the query parameter:

http://localhost/ci4/albumlists/genre1/2384/20 instead http://localhost/ci4/albumlists/genre1/2384?page=2

PHP Code:
<? php
if ($this->uri->segment (4)! = null)
seg $this->uri->segment (4);
$seg 0;
$pg $seg 20;
$prv $seg;
if (
$pg == null)
$pg 20;
$prv 1;
"$prv-$pg of $total title(s).";
}elseif (
$pg > $ total)
"$prv-$total of $total title (s).";
"$prv-$ pg of $total title (s)."

The manual has an example how I can use the segment number instead of the query parameter that would resolve the pending issue, but I'm an old man, everything is slow, I still can't understand where the change is made and how.

<?= $ pager->makeLinks($ page, $ perPage, $ total, 'template_name', $ segment)?>

"When you look at an abyss for a long time, the abyss looks at you."

From time to time I will look at this but only a little.
Once again, thank you very much!

(04-09-2020, 11:00 PM)jouharjaseemak Wrote: finaly i have find a solution...any one want it ?
Yes, Plz share

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.