Problem with pagination class |
[eluser]mradlmaier[/eluser]
Problem with Pagination class I am using pagination on several pages of my site. I have set in my config.php Quote:$config['enable_query_strings'] = TRUE; and also Quote:$config['uri_protocol'] = "REQUEST_URI";(any other uri_protocol would not work) The pagination class generates URL like this: http://flirt-mit-singles.de/privat-chat-...er_page=10 which are wrong URLs. The right ones should be like this: http://flirt-mit-singles.de/privat-chat-...nzeigen/10 Setting $config['page_query_string'] = TRUE in the pagination config array will not change anything.. What is wrong? So far, so good. I found an easy solution by hacking the pagination class itself. But i found that very awkward, because i feel it should never be necessary to touch any of the core of CI. Here is what I did: I changed the create_links function. Basically, when checking for Code: ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) Is that a bug? Any suggestions, comments, ideas?
[eluser]Unknown[/eluser]
I too am having the same problem and I found two ways it could be fixed. Option 1: It seems that setting $config['enable_query_strings'] to TRUE it's what is causing the problem because when I set it back to false I get the nice pagination URLs e.g. Code: http://example.com/site/p/1 Option 2: A database query would normally involve doing something like the following to get the results you want to paginate. Code: $data['results']=$this->table_model->get_results($config['per_page'],$this->uri->segment(3)); Where $this->uri->segment(3) should be equal to an integer. But in our case, $this->uri->segment(3) is instead equal to the string "&per;_page=[page number]", so what I did was I used str_replace to get only the page number. This is what my query line looks like now. Code: $data['results']=$this->table_model->get_results($config['per_page'],str_replace('&per;_page=','',$this->uri->segment(3))); Even though this fixed the problem without messing with CI's core I would still like to know if someone can get the nice URLs working when $config['enable_query_strings']=TRUE Note: This forum is adding a semicolon in my str_replace after "per" that shouldn't be there. |
Welcome Guest, Not a member yet? Register Sign In |