Exemple de pagination compatible CI4:version 4.4.3
PHP Code:
//custom byoosdigital.com
$part_uri = explode('/', uri_string(ADMIN_URL.'user'));
$part_uri = $part_uri[0].'/'.$part_uri[1];
$config = array(
'base_url'=>$self_url,
'query_string_segment'=>'',
'reuse_query_string'=>TRUE,
'use_page_numbers' => TRUE;
'total_rows'=> (int)Models::blogPost()->getCount($conditions),
'uri_segment'=> count(explode('/', $part_uri))+1,
'tab_uri_segment'=> $part_uri,
'per_page'=>10,
);
$this->mkPagination($config);
...
library:
PHP Code:
// custom byoosdigital.com
protected function mkPagination(array $config)
{
$pagination = \Config\Services::pager();
$pagination->setPath($config['tab_uri_segment']);
$pagination->setSegment($config['uri_segment']);
if((int)ceil($config['total_rows'] / $config['per_page']) > 1){
$this->data['pagination'] = $pagination->makeLinks($pagination->getCurrentPage(), $config['per_page'], $config['total_rows'], 'bootstrap', $config['uri_segment']);
}
else{
$this->data['pagination'] = "";
}
}
Lien ci4:pagination
https://codeigniter4.github.io/CodeIgniter4/libraries/pagination.html?highlight=pagination