Search result and pagination class |
[eluser]djalilk[/eluser]
Hi everybody, I need to create a search system with a keyword which displays a large result so I have to use pagination. The problem is: how too keep the keyword variable available for all pagination pages ? I have tried put it in an URI segment but if someone searches a word with forbdiden characters like ' an error is displayed, the 2nd solution is to put it in a session variable but it is totaly ignored by codeigniter. Has anyone faced this problem ? Thank you.
[eluser]umefarooq[/eluser]
last days i did the search controller with pagination, you have keep you keywords with you url to keep it live, than you url is like is Code: http://localhost/ur_site/search/keyword/20 if you calling function than you uri_segment can be 4 well check and accordingly you search will go, im also looking for good solution well its also working fine with me
[eluser]djalilk[/eluser]
Thank you for answering. This solution worked for me but what if the submited keyword contains a forbiden character like "'" ? This is not accepted and will return an error.
[eluser]umefarooq[/eluser]
any example of the forbidden char please put or have you find any problem.
[eluser]djalilk[/eluser]
For exemple if the keyword is "Banque D'a" The following error is returned: An Error Was Encountered The URI you submitted has disallowed characters.
[eluser]umefarooq[/eluser]
then we can do one thing, use php urlencode and urldecode for that, tell where error is coming while search or while pagination,
[eluser]djalilk[/eluser]
This is the url I get when I use urldecode: welcome/search/banque+d'/16/1 And the same error is returned : The URI you submitted has disallowed characters. Below the search method I'm using Code: function search($keyword = null , $city= null ,$offset = null) {
[eluser]TheFuzzy0ne[/eluser]
You can use my URI-safe base_64 encoding helper. http://ellislab.com/forums/viewthread/107741/. It obfuscates the data somewhat, but it works. I also created an alternate URI syntax library which may also help. http://ellislab.com/forums/viewthread/10...10/#551378
[eluser]ray73864[/eluser]
the alternative is to do it how the CI forums do it, which is to store the query if i recall, into a search database along with how many it found and generate a hash for it, then you pass the hash along in the URL.
[eluser]djalilk[/eluser]
Does it mean that every query will be stored in a database ? |
Welcome Guest, Not a member yet? Register Sign In |