CI4:version 4.4.3 compatible paging example

CI4:version 4.4.3 compatible paging example

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'] = "";
 }
    }

Link ci4:pagination
https://codeigniter4.github.io/CodeIgniter4/libraries/pagination.html?highlight=pagination

Comments

Related posts

NodCms Content Manager version2-1

NodCms Content Manager version2-1

update NodCms v3.4.1  to  v3.4.1c

update NodCms v3.4.1 to v3.4.1c

Home - Site powered by CodeIgniter 4.3.0-0 framework - PHP8.2 - LINUX / Debian 11.6 server