[eluser]koichirose[/eluser]
I'm succesfully using pagination in a controller in my website; the code is roughly this (omitting non-relevant parts):
Code:
$this->load->library('pagination');
$config['per_page'] = '30';
$data['poster'] = $this->News_model->get_archivio_posters($config['per_page'],$this->uri->segment(3, 0));
$config['base_url'] = site_url('programma/archivio/');
$config['total_rows'] = $this->News_model->get_total_posters();
$this->pagination->initialize($config);
$this->load->view('header', $data);
$this->load->view('archivio', $data);
$this->load->view('footer');
I'm now trying the same thing on another controller, which has a 4-segments URI:
Code:
$this->load->library('pagination');
$config['per_page'] = '30';
if ($this->uri->segment(3) != 'news') {
$data['poster'] = $this->News_model->get_archivio_posters($config['per_page'],$this->uri->segment(4, 0));
$config['base_url'] = site_url('panel/archivio/live/');
$config['total_rows'] = $this->News_model->get_total_posters();
}
else {
$data['poster'] = $this->News_model->get_archivio_news($config['per_page'],$this->uri->segment(4, 0));
$config['base_url'] = site_url('panel/archivio/news/');
$config['total_rows'] = $this->News_model->get_total_news();
}
$this->pagination->initialize($config);
$this->load->view('header', $data);
$this->load->view('admin_archive', $data);
$this->load->view('footer');
In this second case, the pagination works but if I select page 3 the 'selected' page remains the number 1 (although content and the url change correctly, with the new url being for example /panel/archivio/live/60 ).
The code seems pretty much the same to me, except for the uri-segments....
How can I solve this? Thank you!