By default, the pagination library assume you are using URI Segments, and constructs your links something like

http://example.com/index.php/test/page/20

If you have $config['enable_query_strings'] set to TRUE your links will automatically be re-written using Query Strings. This option can also be explictly set. Using $config['page_query_string'] set to TRUE, the pagination link will become.

OK, that worked. Why do I need to set this? I'm not using URI segments. Also, now I have something like this: http://localhost/index.php/search/?&limit=10 -- the & can be ignored safely, right?
–
StackOverflowNewbieDec 4 '11 at 0:16

Because the stupid uri_segment is default to three ... can ignored safely.
–
ajrealDec 4 '11 at 0:21

i don't have the answer, need to check the code itself. if act like i will put /&limit=20 for after url_segment 2, if the page only have two segment, then is /?&. if not by mistake, once you going to page 2, the link probably will broken again
–
ajrealDec 4 '11 at 0:27

1 Answer
1

I've run into this myself. When using query strings, CodeIgniter has to assume you have other query string parameters (BUT, CI assumes you're using query string parameters to map your controller and method...). I like using query string for stuff like filtering results and such, while still using the basic routing options in the URI (like you).

I've had to live with the ?& personally, but I suppose you could extend the Pagination library like so (long function, sorry):

>> (BUT, CI assumes you're using query string parameters to map your controller and method...) - can you please elaborate on this? I thought you can only map to controller and method using URI segments.
–
StackOverflowNewbieDec 4 '11 at 9:50

The "$config['enable_query_string']" directive was originally used to make your URLs map differently. $_GET['c'] maps to the controller, and I forget the rest. I've never seen someone use it that way, but the Pagination class still reflects that assumption. It thinks it's a safe assumption that there's an existing query string (indicating the controller / action), and it's safe just to append the per_page value and move on. Make sense?
–
landonsDec 4 '11 at 9:56