CodeIgniter Forums
Pagination class won't work for me. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Pagination class won't work for me. (/showthread.php?tid=11404)



Pagination class won't work for me. - El Forum - 09-07-2008

[eluser]Unknown[/eluser]
I'm having some troubles with the pagination class. I've scoured the tutorials both on and off CodeIgniter.com and I just can't get it to work as intended.

The pagination links themselves are showing up just fine, the problem is that there doesnt appear to be any support for the 'current page'.

For example, on my index page I have '1 2 3 > Last >' -- 1 is not a link, it is my current page. 2 and 3 are clickable. When I click them, they work, the content is correct and the correct page is displayed, BUT the pagination code remains the same; '1 2 3 > Last >' with 1 not a link despite the fact I'm on page 2 or 3.

Here is my code:

Code:
function browse($offset)
    {
        $data['images'] = $this->Imagemodel->getTopImages($offset,16);

        $config['base_url'] = '/browse/';
        $config['total_rows'] = $this->db->count_all('images');
        $config['per_page'] = '16';
        
        $this->load->library('pagination');
        $this->pagination->initialize($config);
        
        $data['pagination'] = $this->pagination->create_links();
        
        $this->load->view('header');
        $this->load->view('browse', $data);
        $this->load->view('footer');
    }

What am I doing wrong here?


Pagination class won't work for me. - El Forum - 09-07-2008

[eluser]fatnic[/eluser]
You'll probably need to set
Code:
$config['uri_segment']
to the correct segment.


Pagination class won't work for me. - El Forum - 09-07-2008

[eluser]Unknown[/eluser]
.. Yep. That was it.

Embarassing! Thanks.