Help with Pagination with Paremeters in CodeIgniter

So let’s say I have this URL:

http://localhost/codeigniter/store/category/1/uncategorized

and my controller is function is like this:

public function category($id){
		$config['base_url'] = base_url('store/category/'.$id);
		$config['total_rows'] = $this->PublicPagination_model->getCategoryCount($id);
		$config['per_page'] = 3;
		$config['uri_segment'] = 4;
		$config['full_tag_open'] = '<ul class="pagination">';
		$config['full_tag_close'] = '</ul>';
		$config['attributes'] = array('class' => 'page-link');
		$config['first_link'] = 'First';
		$config['last_link'] = 'Last';
		$config['first_tag_open'] = '<li>';
		$config['first_tag_close'] = '</li>';
		$config['prev_link'] = '&laquo';
		$config['prev_tag_open'] = '<li class="prev">';
		$config['prev_tag_close'] = '</li>';
		$config['next_link'] = '&raquo';
		$config['next_tag_open'] = '<li>';
		$config['next_tag_close'] = '</li>';
		$config['last_tag_open'] = '<li>';
		$config['last_tag_close'] = '</li>';
		$config['cur_tag_open'] = '<li class="page-item active"><a href="#" class="page-link">';
		$config['cur_tag_close'] = '<span class="sr-only">(current)</span></a></li>';
		$config['num_tag_open'] = '<li>';
		$config['num_tag_close'] = '</li>';
		
		$page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
		$this->pagination->initialize($config);
		$data['pagination'] = $this->pagination->create_links();
				
		// Get Posts
		$data['posts'] = $this->PublicPagination_model->getCategoryCountLimit($id, $config["per_page"], $page);

		// Load template
		$this->template->load('public', 'default', 'store/category', $data);

}

in total I have 20 posts but I’m showing 3 per page in the specific page category($id) but it is not working, any help will be appreciated.

This is where the pagination links are supposed to be shown.

I would like to say that I’m displaying data from two tables(using join)… If you guys need me to put my model as well, just tell me!.

You might need to find a CodeIgniter specific forum.

Sponsor our Newsletter | Privacy Policy | Terms of Service