Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 2 Pagination problem
#1

[eluser]Unknown[/eluser]
Hello guys !
I have a problem whit my codeigniter setup , basically the pagination does not work as it should for example :
I can go to page 2 or 3 but you cannot go back to page 1 because page 1 is not a link

here is my code :
Code:
$route['category/(:any)/(:any)'] = 'category/index/$1/$2';
$route['category/(:any)/(:any)/page/(:num)'] = 'category/page/$1/$2/$3';
Code:
public function page($category = '', $filter = '', $page = ''){
   $this->load->model('common');
   $this->load->library('pagination');
   $num_page = $this->uri->segment(4);
  
   // pagination config
   $config['base_url'] = base_url("category/{$category}/{$filter}");
   $config['total_rows'] = $this->common->get_category_users_num($category , $filter);
   $config['per_page'] = '2';
   $config['use_page_numbers'] = true;
  
   $this->pagination->initialize($config);
  
   $data['profiles'] = $this->common->get_category_users($category , $filter , $num_page);
   $data['pagination'] = $this->pagination->create_links();
  
   $this->load->view('header');
   $this->load->view('category' , $data);
   $this->load->view('sidebar_ad');
   $this->load->view('footer');
  }

the website is this : http://goo.gl/iJyCV

any ideas ?

// update
after some quick debuging I've find out that the second route does not work it's remaping to index method not the page method .
#2

[eluser]TheFuzzy0ne[/eluser]
Welcome to the CodeIgniter forums!

I can't even see where your pagination is supposed to be, but if you design your controller a little differently, you can remove one of your routes.

Code:
function index()
{
    $this->page('default_category', 'default_filter', 1);
}

Then this route might do the trick:
Code:
$route['category/(:any)/(:any)(/page/(:num))?'] = 'category/page/$1/$2/$4';

If you really want to do it your way, just switching the routes around might fix it.
#3

[eluser]Unknown[/eluser]
Thank you !
also thank you for your reply I just don't know what happened but now it just works whit no modification .
I think there is a bug somewhere ...




Theme © iAndrew 2016 - Forum software by © MyBB