Welcome Guest, Not a member yet? Register   Sign In
Pagination 404 Error
#1

[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!
#2

[eluser]agdelacruz02[/eluser]
Hi, I have also encountered the same problem the error says
Quote:The requested URL /2 was not found on this server.
I have also tried using
Quote:base_url()
but it still didn't work. Have you found a solution for this? tnx.
#3

[eluser]Aken[/eluser]
You don't need to bump every single thread about pagination. One is sufficient.




Theme © iAndrew 2016 - Forum software by © MyBB