07-14-2012, 05:23 AM
[eluser]Shella[/eluser]
Hi,
I followed tutorial for pagination in an old post undo Nettuts (Day 7) and the tutorial run to me too.
I tried to use the pagination in a project i'm doing then and here I got a surprise.
Actually when I click on the number page to reach (let's say 2) the link I will call is:
http://sub.domain.com/blog/20
and I return "Page not found"!
I'm a bit shocked. Probably I misanderstood some step so... here the code.
I hope somebody can help me to understand what's wrong.
I tried to change different value on $this->uri->segment(2) with 1, 3... 4.. (just because seem "trendy" solve with that heh )
My doubt is when i declare $config['base_url'] but actually nidea. I got "page not found". I guess is senseless if the pagination library is loaded...
Controller:
View
Thanks everybody!
Hi,
I followed tutorial for pagination in an old post undo Nettuts (Day 7) and the tutorial run to me too.
I tried to use the pagination in a project i'm doing then and here I got a surprise.
Actually when I click on the number page to reach (let's say 2) the link I will call is:
http://sub.domain.com/blog/20
and I return "Page not found"!
I'm a bit shocked. Probably I misanderstood some step so... here the code.
I hope somebody can help me to understand what's wrong.
I tried to change different value on $this->uri->segment(2) with 1, 3... 4.. (just because seem "trendy" solve with that heh )
My doubt is when i declare $config['base_url'] but actually nidea. I got "page not found". I guess is senseless if the pagination library is loaded...
Controller:
Code:
public function index()
{
//[...]
$this->load->library('pagination');
$this->load->library('table');
$config['base_url'] = 'http://sub.domain.com/blog/';
//$config['base_url'] = 'http://localhost/ghignos/website_frontend/blog/';
$config['total_rows'] = $this->db->get('articles')->num_rows();
$config['per_page'] = 10;
$config['num_links'] = 20;
$this->pagination->initialize($config);
$data['records'] = $this->db->get('articles', $config['per_page'], $this->uri->segment(2));
$data['main_content'] = 'blog';
$this->load->view('include/template', $data);
}
View
Code:
[...]
<?php echo $this->table->generate($records) ?>
<?php echo $this->pagination->create_links(); ?>
[...]
Thanks everybody!