0

I'm trying to implement pagination using codeigniter. Situation is following: I have only 3 article in my db, so I set per page limit to be 2 to test pagination. Content is property break, inside first page I have first two articles and on second third article. Pagination link numbers are generated correctly.

When I'm on the first page I click on pagination link (2) which loads second page with it's content, but while I'm on this second page pagination link not working on page 1, (1) is not link at all, (2) is linked again?

What can be a problem?

This is my controller method

function pagination()
    {
        $this->load->library('pagination');
        $this->load->library('table');
        $this->load->model('article_m');

        $config['base_url'] = 'http://mysite.com/en/news/pagination';
        $config['total_rows'] = $this->db->get('articles')->num_rows();
        $config['per_page'] = 2;
        $config['num_links'] = 20;

        $this->pagination->initialize($config);        
        $pag = $this->db->get('articles', $config['per_page'], $this->uri->segment(4));        
        $data['records'] = $pag->result();

        $this->template->view('news/pagination', $data);
    }
4

1 回答 1

10

您还需要为您的配置添加它

$config['uri_segment'] = 4;
于 2013-05-28T06:45:47.753 回答