[eluser]Frank Rocco[/eluser]
Hello,
I have an anchor link that passes an id to controller/index and want to display a subset of records.
I tried setting the pagination segment to 4, but when I pass in the link, it messes up the pagination.
When I try and go to the next page, I get no results because catId is set to 5, the next page offset.
Code:
function index()
{
$offset = $this->uri->segment(4,0);
$catId = $this->uri->segment(3,0);
$this->load->library('pagination');
$perpage = 5;
$config['base_url'] = base_url() . 'index.php/category/index';
$config['per_page'] = $perpage;
$config['uri_segment'] =4;
$config['total_rows'] = $this->category_model->getRecords(array('count' => TRUE, 'cat_parent_id' => $catId));
$this->pagination->initialize($config);
$data['total_rows'] = $config['total_rows'];
$data['pagination'] = $this->pagination->create_links();
$data['results'] = $this->category_model->getRecords(
array('limit' => $perpage,
'offset' => $offset,
'cat_parent_id' => $catId,
'sortBy' => 'cat_name',
'sortDirection' => 'ASC'
));