CodeIgniter Forums
About pagination - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: About pagination (/showthread.php?tid=1033)



About pagination - rakibtg - 02-07-2015

I am using CI3 and the pagination is not working on the second page. Is that i am missing something? Here is my code from the controller:
PHP Code:
public function tags($task "list")
    {
        
$header['title'] = 'Tag List';
        
$this->load->view("template/header"$header);
        
$this->load->view("template/dashboardNavView");

        
$builder ['task'] = $task;

        if(
$task == "list" || $task == "")
        {

            
$pager['base_url'] = "/dashboard/tags/";
            
$pager['total_rows'] = $this->db->count_all('tags');
            
$pager['per_page'] = 4;
            
$pager["uri_segment"] = 3;
            
$this->pagination->initialize($pager);

            
$page $this->uri->segment(3);

            
$builder['tags'] = $this->db->order_by('id''DESC')->limit($pager['per_page'], $page)->get('tags')->result();
            
$builder['pager'] = $this->pagination->create_links();

        }

        
$this->load->view("tags/TagsBuilderView"$builder);
        
$this->load->view("template/footer");
    } 

Everything seems ok, but when i click on the second link then empty view returned.


RE: About pagination - Rufnex - 02-07-2015

Try to this without the / ...

$pager['base_url'] = "/dashboard/tags";


RE: About pagination - rakibtg - 02-07-2015

Thankyou for your response, i tried with
$pager['base_url'] = "/dashboard/tags";
but it doesn't work also i tried with full url with no success.


RE: About pagination - Rufnex - 02-07-2015

What about $pager['base_url'] = "/dashboard/tags/list";


RE: About pagination - rakibtg - 02-07-2015

Many thanks @Rufnex for your time, you point me into the right direction. However shipping everything into a new method seems works just perfect! Smile


RE: About pagination - Rufnex - 02-07-2015

Glad to help you Wink