CodeIgniter Forums

Full Version: Problem with Pagination
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I already using the pagination library in nearly ten modules, with no problems, but it fails in last one (and the most important).

My routing for this section is:

$route['candidate/sort/(:any)/(:any)/page/(:num)'] = 'candidate/sort/$1/$2/$3';

Pagination config on the controller:

/* Pagination */
# Config Pagination
$data['cms']['tables']['total_rows'] = $total; # Total works
$data['cms']['tables']['per_page'] = $this->limit; # Limit = 1
$data['cms']['tables']['first_url'] = base_url($data['sub_active'].'/sort'.'/'.$type.'/'.$id);
$data['cms']['tables']['base_url'] = base_url($data['sub_active'].'/sort'.'/'.$type.'/'.$id.'/page');
# Initialize Pagination
$data['pagination'] = $this->pagination->create_links();

Base first url =$type/$id and base url =$type/$id/page

But the pagination doesn't work, it always the same page (page 1 on this case)

Thanks in advance.

El Forum

I would guess the problem is your model, and not your pagination code. (although it appears 'base_url' could use a trailing slash). I would guess that you are passing the wrong uri segment in your model to fetch the rows. Since you are using routing, you may want to use rsegment() method. Echo the page offset in your model/controller, to see if you are getting the correct segment when fetching the database.

El Forum

I don't see anything where you've told the pagination library what segment to use for the page number. It doesn't automatically know which one you need, you have to tell it.