• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to create paging with form search, but query string enable??

#2
[eluser]JoostV[/eluser]
I'm not sure what it is you're asking for, but anyway.

By default query string (?foo=bar) is not enabled. This does not have to be a problem, though. Actually, your app is safer this way, so it's a good thing.

Now to build a search module:
1. create a controller search/redirect, that creates a string that you can use to redirect to another controller, search/result. Your search form should post to search/redirect.

Code sample for search/redirect:
Code:
if ($this->validation->search_string) {
    // Replace spaces with slashes so we get a uri to redirect to
    $uri = str_replace(' ', '/', $this->validation->search_string);
    // Redirect to the result controller, adding a segment for each search string.
    // E.g. serach/results/my/search/string
    redirect('search/results/' . $uri, 'refresh');
}
2. In your controller search/result you can fetch the search strings from the uri and perform your search.
3. You can use paging without having to store the search strings anywhere. You can always access the search strings because they are in your uri.

As an added bonus: you search will become more user-friendly because users can now:
1. search by typing serach strings in the uri instead of posting
2. deeplink to serach results, or store them in favorites


Messages In This Thread
how to create paging with form search, but query string enable?? - by El Forum - 11-28-2008, 03:27 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.