I am learning codeigniter these days. I have done a website for my own use a couple of days ago where i have just applied pagination today but it seems there is problem with my url rewriting.
Here is my action inside my controller which grabs list of authors in a category
`public function index() { $data['main_content'] = "templates/public/audio/author_view"; $data['authors'] = $this->author_model->get_authors(); $this->load->view("templates/public/template",$data); }`
Here is my function that grabs value from db located inside my author model `public function get_authors($type = 0) { $this->db->select("author.name,author.image,author.slug"); $this->db->from("author"); $this->db->join("album","author.id = album.author_id"); $this->db->where("album.mime_type",$type); $this->db->group_by("author.name"); $query = $this->db->get(); return $query->result(); }`
When i clicked on one of author grabbed it open all albums of selected author. then url looks link www.xyz.com/audio/album-name
Here is my code for this route.
$route['audio/(:any)'] = "audio/view_author_album";
At this stage it works fine. But now today when i applied pagination i found that this route will not do more work for me. I have added pagination in my index action Below you can see my code
public function index() { $config['base_url'] = "http://localhost/mywebsite/audio/index/"; $config['total_rows'] = $this->author_model->get_total_rows(); $config['per_page'] = 1; $this->pagination->initialize($config); $data['main_content'] = "templates/public/audio/author_view"; $data['authors'] = $this->author_model->get_authors($config['per_page'], $this->uri->segment(3)); $this->load->view("templates/public/template",$data); }
This open the details http://localhost/mysite/audio/index/2
against this url my route rule $route['audio/(:any)/(:any)'] = "audio/view_album_details"; works.
It should grab the next page instead of my detail view.
And url should be something like http://localhost/mysite/audio/2
I also tried $route['audio/(:num)'] = "audio/;
I will highly appropriate if anyone can help me in solving this problem.