Welcome Guest, Not a member yet? Register   Sign In
How does the pagination class work?
#3

[eluser]waynhall[/eluser]
It sends a value (the offset) to the function at the url specified in config. (Which is the same as uri segment 3)
controller/function/$offset

You can access its value by placing a parameter on your index() function:
Code:
function index($offset) {

In your case, as you click next, you'll go to:
/books/index/5 // $this->index(5)
/books/index/10 // $this->index(10)
/books/index/15 // $this->index(15)
... and so on.

Its zero based, so going to the url books/ is the same as
/books/index/0

I usually create a separate function (not index) that handles the pagination:
Code:
public function index()
    {
            $this->page();
    }
    
    public function page($page = 0, $type = '') {
        
        $this->load->model('news_posts');
        $count = $this->news_posts->get_count($type);
        
        $per_page = 3;
        if($type == 'recipe') {
            $per_page = 10;
        }
        
        $title = 'News';
        
        
        $this->load->library('pagination');
        $config = array(

// blah blah blah


Messages In This Thread
How does the pagination class work? - by El Forum - 08-03-2011, 04:44 AM
How does the pagination class work? - by El Forum - 08-03-2011, 05:51 AM
How does the pagination class work? - by El Forum - 08-03-2011, 05:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB