[eluser]happydude[/eluser]
I have just been trying to get the pagination library to work to no avail.
Pagination works fine at other parts of the application where I am working on except this part.
The problem is that when I open the page. The pagination works fine, but when I click any other number in the pagination links, the cur_tag_open and the cur_tag_close are still set to the first page (1). Also, its link points to the current page on which it is located, so rather than have categories/1, I have categories/1/18 as the link on it.
Here is my code below:
Code:
function index($slug='', $id='', $offset=0)
{
if ( ! ($slug && $id ) ) { //No params? Bounce to home page
redirect ('home');
}
$products_per_page = 6;
$this->data = $this->category->get($id);
$this->_sidebar(); //Generate the sidebar.
$this->data['products'] = $this->product->get_products($products_per_page, (int)$offset, (int)$id, 'category');
//Generate Pagination
$this->load->library('pagination');
$config['base_url'] = base_url().'categories/'.$slug.'/'.$id.'/';
$config['total_rows'] = $this->product->count_by('category_id', $id);
$config['per_page'] = $products_per_page;
$this->pagination->initialize($config);
var_dump($config['total_rows']);
$this->data['pagination'] = $this->pagination->create_links();
}