• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination Detection

#5
[eluser]Craig A Rodway[/eluser]
In the controller where I use pagination, the index() function is the main listing page, and the p() function handles the pages. If you check the contents of $offset, you can determine if you are on the index page or on a paginated page. Hope this code helps...

Code:
function index(){
        return $this->p();
    }

Code:
function p(){
        
        $limit = 5;
        $offset = $this->uri->segment(3, 0);
        
        $config['per_page'] = $limit;
        $config['base_url'] = site_url('news/p');
        $config['total_rows'] = $this->newsmodel->count();    
        $this->pagination->initialize($config);
        
        $body['news'] = $this->newsmodel->get(NULL, NULL, TRUE, $limit, $offset);
        
        $tpl['title'] = 'News';
        $tpl['body'] = $this->load->view('news/index', $body, TRUE);
        $tpl['sidebar_activities'] = $this->activitymodel->get_sidebar();
        $this->load->view(TEMPLATE, $tpl);
        
    }

/news/ = index()
/news/p/5 = p()


Messages In This Thread
Pagination Detection - by El Forum - 12-31-2009, 09:45 AM
Pagination Detection - by El Forum - 12-31-2009, 09:54 AM
Pagination Detection - by El Forum - 12-31-2009, 10:32 AM
Pagination Detection - by El Forum - 12-31-2009, 04:10 PM
Pagination Detection - by El Forum - 12-31-2009, 04:30 PM
Pagination Detection - by El Forum - 01-01-2010, 09:19 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.