Codeigniter pagination |
[eluser]khagendra[/eluser]
Here is Your code Code: $pagination_config['base_url'] = base_url().'index.php/quotes/showchapter/'.$chapter_id.'/'; -- I think u need to do some changes 1. Load the library pagination in ur controller(u can load in constructor function) Code: $this->load->library('pagination'); 2. Where u have written the Query in ur code Code: $pagination_config['total_rows'] = $query->num_rows(); // $query ??? 3. According to ur $pagination_config['base_url'] = base_url().'index.php/quotes/showchapter/'.$chapter_id.'/';, I think uri_segment should be 4 Code: $pagination_config['uri_segment'] = 4; 4. Have u retrieved the list of data from any table with limit and offset valu, here is one line of code that u can write before $this->pagination->initialize($pagination_config); like this Code: $data['data_list'] = $this->model_name->function_name($config['per_page'],$this->uri->segment(4)); 5. Here is the model function name example Code: function function_name($limit, $offset) 6.last thing, u should have to write this line in ur view file to show links Code: echo $this->pagination->create_links(); Hope this will help you
[eluser]RomanN[/eluser]
No, with 6 didn't work too. Look, the url segment is changed correctly. I was on the 1-st page and my url was next: Quote:http://localhost/quotes/index.php/quotes...hapter/1/0Then I shifted to second page, data changed, the url became: Quote:http://localhost/quotes/index.php/quotes...hapter/1/1 Seems correct, the last number was incremented, but url links represent first page as active.
[eluser]RomanN[/eluser]
[quote author="khagendra" date="1256663293"]Here is Your code Code: $pagination_config['base_url'] = base_url().'index.php/quotes/showchapter/'.$chapter_id.'/'; -- I think u need to do some changes 1. Load the library pagination in ur controller(u can load in constructor function) Code: $this->load->library('pagination'); 2. Where u have written the Query in ur code Code: $pagination_config['total_rows'] = $query->num_rows(); // $query ??? 3. According to ur $pagination_config['base_url'] = base_url().'index.php/quotes/showchapter/'.$chapter_id.'/';, I think uri_segment should be 4 Code: $pagination_config['uri_segment'] = 4; 4. Have u retrieved the list of data from any table with limit and offset valu, here is one line of code that u can write before $this->pagination->initialize($pagination_config); like this Code: $data['data_list'] = $this->model_name->function_name($config['per_page'],$this->uri->segment(4)); 5. Here is the model function name example Code: function function_name($limit, $offset) 6.last thing, u should have to write this line in ur view file to show links Code: echo $this->pagination->create_links(); Hope this will help you[/quote] Man, of course I've loaded library, wrote db query and created pagination links. I showed only the part of code. And as I've already said pagination works well in other method. But, you really helped me!!! when I changed Code: $pagination_config['uri_segment'] = 4; Thank you all, people.
[eluser]ericrjones1[/eluser]
The third (3) uri_segment is set as the default uri_segment parameter of CI_Pagination class. So to have your pagination work correctly you need to set the uri_segment parameter to the dynamic pagination uri_segment Code: $config['uri_segment'] = 4 but also make sure that you are using the same uri_segment as part of your query offset Code: $data['foo'] = $this->foo_model->get_bar($config['per_page'], $this->uri->segment(4)); but just to make sure that you are cleaning and appropriately handling the incoming data from $this->uri->segment(4) because that is basically a $_GET variable
|
Welcome Guest, Not a member yet? Register Sign In |