Welcome Guest, Not a member yet? Register   Sign In
Pagination and routing
#1

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
    

   
Reply
#2

(:any) is a catch all! Look at your commands and then rearrange them.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(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) { ?>
Reply
#4

Try using just site_url() alone.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 01-26-2016, 08:12 PM by meow.)

(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'
Reply




Theme © iAndrew 2016 - Forum software by © MyBB