Welcome Guest, Not a member yet? Register   Sign In
pagination not working - help
#1

[eluser]jcjc[/eluser]
Building a first pagination page on a blog I'm creating and it's not currently working, can anyone help?

Code is:
Code:
$this->data['blog'] = $this->blog_model->_get_all_posts();

  $this->load->library('pagination');

  $config['base_url'] = base_url() . 'home/';
  $config['total_rows'] = $this->blog_model->_count_all_posts();
  $config['per_page'] = 2;
  $config['uri_segment'] = '2';  
  $this->pagination->initialize($config);
  $this->data['pagination'] = $this->pagination->create_links();

  $this->load->view('home_view', $this->data);

on the front I just have a blog foreach loop with <?php echo $pagination; ?> at the end.

I get the 404 error page.

thanks.
#2

[eluser]CroNiX[/eluser]
try adding the method (it looks like you just have controller) in the base_url, and use segment 3 for uri_segment.
#3

[eluser]jcjc[/eluser]
How do you mean?
#4

[eluser]CroNiX[/eluser]
Code:
$config['base_url'] = base_url() . 'home/';
You only have controller name, home. You need a method too.

Code:
$config['uri_segment'] = '2';
Then change that to 3

See the example in the user guide
#5

[eluser]jcjc[/eluser]
got it - thanks, is there a way to remove controller and method from url structure?
#6

[eluser]CroNiX[/eluser]
You can use routes to do that, although I'm not sure how you'd be able to remove the controller name unless you only have one controller in your entire app. How do you want the url to look? http://yoursite.com/30, where 30 is the pagination offset?
#7

[eluser]jcjc[/eluser]
Managed to figure it out - the moment you said routes it clicked, have got it to = blog/page/2. Thanks for your help, glad to see the community is still behind this awesome framework.




Theme © iAndrew 2016 - Forum software by © MyBB