Welcome Guest, Not a member yet? Register   Sign In
search and pagination
#1

[eluser]tzi0[/eluser]
Hi all. I have a problem with my search, dont know how to solve it. I have a form with text input for search string and i want my results was paginated. but it works only if i type search string for the first time and then submit my form (because my search string goes to my script via post, and when i click,for example, second paginated link, my $this->input->post('search_string') stands empty) =(
#2

[eluser]Maglok[/eluser]
You can put the search in a variable which you pass to the search function through uri segments?
#3

[eluser]tzi0[/eluser]
yes, but how to do it with pagination?
will try
#4

[eluser]davidbehler[/eluser]
Search term in uri isn't such a good idea I think. What if someone searches for something which contains a character that's not allowed in the url? He would see an ugly error Smile

I would rather store the search term in the session and check for it everytime the page is loaded. If the user accesses the page without pagination info, e.g. /search you can reset the term as he propably wants to search for something else. If he navigates back to page x, e.g. /search/x you can use the search term from the session to determine how many search results there are.

Another solution would be to save the performed search in your database and generate a unique key for each search. Then you can just pass the unique key in the url and use that.
#5

[eluser]tzi0[/eluser]
thanks guys!
#6

[eluser]Vega[/eluser]
I have used the second method waldmeister described before and I think it works well. However the URL is not so search friendly. What you could do is strip out all the characters that you don't want in the URL then something like 'my~***search} params;;' becomes 'my-search-params'.

Your uri would look something like: /results/my-search-params/uniquekeyhere
#7

[eluser]tzi0[/eluser]
it works now! =)
every time page is loaded (in my auth library, %) ) i intercept $this->input->post('search_string') and store it in my session, if my segment is not "search" i reset session search data. In my controller method i use session data insted post data.
#8

[eluser]davidbehler[/eluser]
Vega, the function you are looking for is url_title()




Theme © iAndrew 2016 - Forum software by © MyBB