Welcome Guest, Not a member yet? Register   Sign In
Pagination With Search
#1

[eluser]sszynrae[/eluser]
Hi, I'm wondering if anyone have come across this situation before:

as the CI pagination class needs to work with a fixed uri I decided to include the search string as one of the uri segments. im using a simple form to combine my search options and redirect to the correct uri.

the problem is that the allowed character set in a CI uri is much smaller than what a user is allowed to type into an html form. So if the user types 'beer&wine;' say, the CI illegal character error will occur. does anyone know a way to bypass this?

I thought perhaps extracting illegal characters from the search string before redirect, but the allowed character set for CI is 'a-z 0-9~%.:_-', which i have no idea how to work with.

any help would be greatly appreciated!
#2

[eluser]devbro[/eluser]
here is how i would do it:

1. create a form and make it submit using POST
2. in your search result, put the post data in session
3. since search data is in session you no longer need to worry about uri and characters
4. setup pagination on search result page

Wink
#3

[eluser]egoslip[/eluser]
[quote author="devbro" date="1248420890"]here is how i would do it:

1. create a form and make it submit using POST
2. in your search result, put the post data in session
3. since search data is in session you no longer need to worry about uri and characters
4. setup pagination on search result page

Wink[/quote]

Ya I agree with devbro on how to do it but I would set a flashdata session instead of a regular session then just reset it when they go to the next page. that way if they leave the search pages they don't have any unnecessary session data.

Atleast that how I do it.
#4

[eluser]devbro[/eluser]
cookie should do it too. my one problem with session is that if they wait between pagings it may get lost.
One other thing that may matter, do you care if url is portable?
#5

[eluser]sudesh[/eluser]
[quote author="egoslip" date="1248434701"][quote author="devbro" date="1248420890"]here is how i would do it:

1. create a form and make it submit using POST
2. in your search result, put the post data in session
3. since search data is in session you no longer need to worry about uri and characters
4. setup pagination on search result page

Wink[/quote]

Ya I agree with devbro on how to do it but I would set a flashdata session instead of a regular session then just reset it when they go to the next page. that way if they leave the search pages they don't have any unnecessary session data.

Atleast that how I do it.[/quote]

This way is not google friendly and u cannot use your search results as bookmarks

for example - http://www.google.co.in/search?hl=en&q=c...&oq=codeig

if you copy and paste it you will get the search result back without any session.
#6

[eluser]sszynrae[/eluser]
[quote author="sudesh" date="1248438650"]
This way is not google friendly and u cannot use your search results as bookmarks

for example - http://www.google.co.in/search?hl=en&q=c...&oq=codeig

if you copy and paste it you will get the search result back without any session.[/quote]


Yeah, i would rather work with a small set of characters and have a fixed search url, than to have session based things going. Especially with inactivity issues. Is there a good way to encode a search string on submit and decode it in the controller?
#7

[eluser]davidbehler[/eluser]
Just save the parameters used for the search in your database and create a unique key for each search.
Now you can use that key in the url to access a search that was performed before.

Try my search library or build one yourself, it's not that difficult.
#8

[eluser]sszynrae[/eluser]
yeah, that would work, I might do that.

Just a question though, and I'm not great at SQL performance here but wouldn't that quickly create an enormous table? Would that would that not matter much, as it's only inserting/fetching one row from it per search/browse?




Theme © iAndrew 2016 - Forum software by © MyBB