Welcome Guest, Not a member yet? Register   Sign In
ci4:version 4.4.3 Pagination
#1

Hello CI4,
I am working on a CI4 application with manual pagination, I have a problem with URL on the following pages, OK
http://localhost/1__codeigniter_dev/public/en/blog/1
then the following pages...
http://localhost/public/en/blog/1/2
error 404
??? an idea, below the code controllers
PHP Code:
        //custom byoosdigital.com
 
$part_uri uri_string($self_url);
        $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'] = "";
 }
    
Reply
#2

See https://codeigniter4.github.io/CodeIgnit...uri_string
Reply
#3

(11-18-2023, 06:59 PM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgnit...uri_string
Thanks @kenjis,
For having put me on the right path, the uri_string() function actually returns the segments following base_url(), I had completely missed that with URI pagination increases by one HO segment

FIX code

PHP Code:
          //custom byoosdigital.com
$part_uri explode('/'uri_string(ADMIN_URL.'user'));
$part_uri $part_uri[0].'/'.$part_uri[1]; 
Thanks you boss
Reply




Theme © iAndrew 2016 - Forum software by © MyBB