MyBB Community Forums

Full Version: Search terms in search URL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
When you search, you get something like this:

http://community.mybboard.net/search.php?action=results&sid=6fb10fbee85f8547905db358267c667e&sortby=lastpost&order=desc

Is there any way to include the terms in there too?? Something like &terms=each+term+here?? I'm using labrocca's search log plugin which gives me the info I need (i.e. what people have searched for), but I also need this to try something out outside of MyBB itself, and it needs the search terms in the URL to achieve this. Not really keen on core file edits so if it would need that, I won't bother.
You mean just append the terms even though it has no purpose? The idea of the sid's is to cache searches for multipage/sorting.
http://localhost/MyBB/search.php?action=...+term+here

works if you change search.php

elseif($mybb->input['action'] == "do_search" && $mybb->request_method == "post")

to

elseif($mybb->input['action'] == "do_search")

In theory it'd also be possible to do this in a plugin but it doesn't seem worth the effort.

External search plugins such as the Firefox quick search bar, do not need this modification, they can send this as post requests.
(2009-03-23, 11:49 AM)Yumi Wrote: [ -> ]You mean just append the terms even though it has no purpose? The idea of the sid's is to cache searches for multipage/sorting.

Has a purpose for me, as I said, the terms need to be in the URL itself after a search so I can trace them outside of MyBB.

(2009-03-23, 11:51 AM)frostschutz Wrote: [ -> ]works if you change search.php

elseif($mybb->input['action'] == "do_search" && $mybb->request_method == "post")

to

elseif($mybb->input['action'] == "do_search")

Thanks, but isn't quite what I need, I need to have the terms in the URL of the search results, not have them in the URL to do the search to begin with.
OK, in that case you're looking for redirect() calls in search.php and add &keywords={$keywords} or similar to the redirect URL (however that'll be a bogus parameter in the URL that isn't actually interpreted by MyBB, it just sits there).

In a plugin you'd have to hook into search_results_start, if keywords arent in the query string, look up keywords from the searchlog table according to sid, and then redirect to the URL with the keywords appended in the query string.
Yes it would let the users to search right from the MyBB panel, nicely done frostuuze
As I understand it, MyBB caches the search result first, and puts the search ID into the database, then redirects itself. I think every now and then the search IDs are purged, so if I understand correctly the OP's intention, just appending the search terms to the search results URLs would not be that good.
The details collected from the URLs are stored in a different table so even when the search expires, they words used will still be visible for me.
Umm, I think I've misunderstood your intention. What do you mean by "so I can trace them outside of MyBB"?

I was thinking along the lines of http://www.google.com/search?q=mybb to output Google's result for pages containing the string "mybb".
Yeah, that's all I need. Then something else can get the terms from that parameter.
Pages: 1 2