Welcome Guest, Not a member yet? Register   Sign In
Integrating search terms in the URL query string
#1

[eluser]taewoo[/eluser]
I am trying to write my own search function. But upon writing it, I realized getting the search result page number is a b*tch... so I thought of integrating the search term into the URL along but I am not certain how this is done b/c of the code igniter "clean URL" feature.

How can i either

1) pass a $_POST variable from one page to the next

or

2) include "page number" into the URL in CI - acceptable way ? (i've noticed some of the MVC driven sites have string like "http://x.y.z/search/find+me"

ANy hints?
#2

[eluser]Seppo[/eluser]
For the first item, you can store the data in the session and only pass the page number.
You can use the 2nd style, or you can do something like CI Forums does: a hash that identifies the search.

The method I think it's the best is the first one, specially if you have many fields and not only a search box.
#3

[eluser]gabe[/eluser]
You can also use a hidden field in the form that contains the value you want to pass. That will be available in the $_POST array.
#4

[eluser]taewoo[/eluser]
Thanks guys. Both good suggestions.
But isn't it more beneficial to #2 since some people might want to bookmark the search result or link it to their page?

Seppo: I am not sure what your referring to ... a hash? Can you explain or forward me to the right resource? thanks in advance.
#5

[eluser]gabe[/eluser]
I haven't done this myself as I haven't needed. But you might want to create a new route. Setup a search controller, and then you can make it so that the second uri segment is the search term. Look at the routing section of the user guide, I'm afraid I can't help you so much with this particular aspect.

If/when you do find a solution for this please be kind enough to post a reply as I think several other people (including me) would the answer interesting!
#6

[eluser]Seppo[/eluser]
[quote author="taewoo" date="1203205545"]Seppo: I am not sure what your referring to ... a hash? Can you explain or forward me to the right resource? thanks in advance.[/quote]Search something on this forums, and then check out the URL. It will be something like this
http://ellislab.com/forums/search_result...e2e1dabb2/ and then, the "next" link will let you to
http://ellislab.com/forums/search_result...dabb2/P20/ so 70586a7c96225416b25186de2e1dabb2 is the key for your search and probably it's store someplace in the server what it means.




Theme © iAndrew 2016 - Forum software by © MyBB