[eluser]Unknown[/eluser]
Hello forum!
I am having problems with Code Igniters pagination module.
When I go to click on the links I get a 404 error. As I understand and I may be incorrect, but it would seem that the uri segment which determines the offset is not being read inside the index function of my controller and that code igniter is actually looking for this as a function inside the controller hence throwing the 404 when it can't find it.
I have googled around and checked on the forum to find a solution but have not had any success. If anyone has any hints or tips that would be great I have included the relevant code from my controller, model and view below.
//Controller
Code:
$this->load->library('pagination');
$config['base_url'] = '/yourhistory/';
$config['total_rows'] = $this->db->get('gallery')->num_rows();
$config['per_page'] = 3;
$config['uri_segment'] = 2;
$this->pagination->initialize($config);
$data['galleryitems'] = $this->pages_model->get_gallery($config['per_page'], $config['uri_segment']);
$this->load->view('/gallery', $data);
//Model
Code:
function get_gallery($limit, $segment)
{
$query = $this->db->get('gallery', $limit, $this->uri->segment($segment));
if ($query->num_rows > 0)
{
foreach($query->result() as $row)
{
$data[] = $row;
}
return $data;
}
}
//View
Code:
echo $this->pagination->create_links();
Thanks!