CodeIgniter Forums
Pagination and routing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Pagination and routing (/showthread.php?tid=64198)



Pagination and routing - meow - 01-26-2016

I've read several archived posts from Ellislab about pagination and I dont understand why its not working. URLs are my weakness and http in general.

Help!?

In routes.php I have (second line down)

PHP Code:
$route['log/delete_img/(:any)/(:any)/(:any)'] =     'logs/delete_image/$1/$2/$3';
$route['log/(:any)/page/(:any)'] =             'logs/log/$1';
$route['log/(:any)'] =                     'logs/log/$1';
$route['log/(:any)/(:any)/date'] =             'logs/change_date/$1/$2';
$route['log/(:any)/(:any)/text'] =             'logs/edit_entry/$1/$2';
$route['log/(:any)/edit/(:any)'] =             'logs/edit/$1/$2'

and

PHP Code:
    //'uri_segment'        => 3,
    
'base_url'        => site_url() . '/log/' $slug,
    
'prefix'        => '/page/',
    
'total_rows'        => $this->user_model->get_count_entries($plantid),
    
'per_page'        => 2


controller
PHP Code:
    public function log($slug NULL) {
        
//method code here
    

   


RE: Pagination and routing - InsiteFX - 01-26-2016

(:any) is a catch all! Look at your commands and then rearrange them.


RE: Pagination and routing - meow - 01-26-2016

(01-26-2016, 10:51 AM)InsiteFX Wrote: (:any) is a catch all! Look at your commands and then rearrange them.

Thanks! I moved it all the way down but nothing changes. I think the view is incorrectly set up. Maybe the docs dont explain the logic enough? Missing something!! or my brain is missing something too!

Here's the start of the view
PHP Code:
    <?php if (!empty($log_entries)) { ?>
    <?php foreach ($log_entries as $plantitem => $data) { ?>



RE: Pagination and routing - InsiteFX - 01-26-2016

Try using just site_url() alone.


RE: Pagination and routing - meow - 01-26-2016

(01-26-2016, 03:14 PM)InsiteFX Wrote: Try using just site_url() alone.

Thanks.

I dont know Portuguese, but this youtube vid helped by Géssica Andrade @
https://www.youtube.com/watch?v=6IfIUsLVY2s

I was missing the following and I'm not sure what its doing in the controller, but its working:

PHP Code:
$inicio = (!$this->uri->segment('4')) ? $this->uri->segment('4'); 

and then part of the pagination config

PHP Code:
        $config = array(
            
'uri_segment'            => 4,
            
'base_url'            => site_url() . '/log/' $slug,
            
'prefix'            => '/history/',
            
'total_rows'            => $this->user_model->get_count_entries($plantid),
            
'per_page'             => $maximo
            
);

        
$this->pagination->initialize($config);
        
$data['paginationbar'     $this->pagination->create_links();
        
$data['log_entries']         = $this->user_model->get_log_entries($plantid,$maximo,$inicio); 
and I moved my routing to the downward most possible position:
PHP Code:
$route['log/(:any)/history/(:any)']         = 'logs/log/$1';
$route['blog/(:any)']             = 'blog/view/$1';
$route['blog']                 = 'blog';
$route['default_controller']         = 'pages/view';
$route['(:any)']             = 'pages/view/$1'