Welcome Guest, Not a member yet? Register   Sign In
Bookmarkable, paged, advanced search without query strings?
#1

[eluser]TheFuzzy0ne[/eluser]
Hi everyone. I've been pondering for about a week, and I still can't figure out how to do a search function which is bookmarkable and doesn't rely on cookies.

Can anyone think of an elegant solution to this problem, other than to cache users search terms in the database, and redirect them to the results (which I am assuming the search function for this site does, too)? I feel this is the simplest solution, but I can't figure out if there's a better way.

The advanced search will have to encompass other variables too, such as which categories to search under, etc...

Many thanks in advance.
#2

[eluser]xwero[/eluser]
you can add segments using the uri->assoc_to_uri method.
#3

[eluser]drewbee[/eluser]
Hi Fuzzy,

I am a little confused. Can you please elaborate?

If I were to do a search, it would be something similar via the controller:

function search($term = '', $page = '1')
{

}

then accessed via the URL /my+search+term/3.html

Although one of the downsides is the restriction to available characters in the uri.

The database search is a good one, and something similar is used on this forum search:
'my+search+term' is queried, md5() it and now that is your new link.

The database contains the md5() version and the keywords. Then the url would be something similiar too:

/search/asfd087fas7d8fsf08a9dfs90as/1.html
#4

[eluser]xwero[/eluser]
I would urldecode the input instead of creating an md5 hash.
#5

[eluser]TheFuzzy0ne[/eluser]
Hi. Thank you both for your replies.

@drewbee: I was considering doing something along the lines of hashing the keywords, but I'm not sure how I would handle things such as a search within certain categories, or posts within certain forums. That's easy enough to do with $this->input->post(), but once the query has been made, the post variables are lost, and won't be passed over to the next page. The way to do this then would be to have my pagination as a form, but a simple refresh of the page would probably break it.

I'm sure I can find a way around the problem, but I would like to get some ideas on a more flexible way to do this. I'm quite sure I am not the first person to want to do this. On the other hand, I could always bring back query strings, as that would make life so much simpler. Perhaps advanced searching and query strings go hand in hand?

I am currently looking into creating a forum that's built on CI (as part of a paid project), and if it's ever good enough, I'll GPL it.

Thanks again for your help.
#6

[eluser]TheFuzzy0ne[/eluser]
[quote author="xwero" date="1234135693"]I would urldecode the input instead of creating an md5 hash.[/quote]

I like that idea, although it doesn't help with extra functionality, such as how many results should be visible per page and such. Ultimately, I guess there's no way to do it without forcing the user to use cookies. The cookies would then store such settings.

I think another perk of doing an MD5 hash, is that the URI looks nicer. But thanks for your input. It's an idea I hadn't considered, and I just might.
#7

[eluser]davidbehler[/eluser]
To be honest I have not read all posts in this topic, but I guess a library of mine could help you:
MeNeedz Search

Every search that is performed is assigned a unique id and can be perform again and again whenever you want as the used where constraints are saved in the database.

Have a look, maybe that's the right thing for you.
#8

[eluser]TheFuzzy0ne[/eluser]
Judging by the allowed URI characters, I think urlencode() and urldecode() would work great. It's as if CodeIgniter was built with this problem in mind. It would also mean that search pages can be bookmarked, as with codeigniter.com's current system, the MD5 hash is removed from the database after a few hours, so any bookmarks to search results are rendered useless.

Thanks again to you both for your input.
#9

[eluser]TheFuzzy0ne[/eluser]
[quote author="waldmeister" date="1234137000"]To be honest I have not read all posts in this topic, but I guess a library of mine could help you:
MeNeedz Search

Every search that is performed is assigned a unique id and can be perform again and again whenever you want as the used where constraints are saved in the database.

Have a look, maybe that's the right thing for you.[/quote]

Thanks for your reply. Using url(en/de)code(), I don't have to waste any database space. Thanks for the link, though.
#10

[eluser]drewbee[/eluser]
Nice one xwero! I didn't even think of that; that would work out perfect.

Fuzzy,

I trust you understand now how to save the categories? Create some type of separator between categories, other attributes, and the search term.

IE. using a dash, comma or something simliar. It would be wise to try and use something that wont be searched upon though; For instance, if a user types in a comma, I would probably strip it out due to the fact that you are simply searching upon keywords anyways:

urlencode(catname,attribute1,search+terms)

and after the decode, a simple explode for all your needed parts.




Theme © iAndrew 2016 - Forum software by © MyBB