MyBB Community Forums

Full Version: How does the search feature work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like to tap into the search feature, but have looked through the code and made an example that I thought would work and it tells me its an invalid search.

Here's what I tried; I'm just trying to make a link that uses the search feature
$sid = md5(uniqid(microtime(), 1));
echo '<a href="search.php?action=results&sid='.$sid.'&sortby=lastpost&order=desc&keywords='.$word.'">Search for $word here</a>';

Can someone explain to me what I'm missing here? Does something else need to happen that I didn't see when looking through the code?
If you just want a link to the search page try this.
<a href="http://YOURWEBSITE.com/search.php">Search</a>
*Change YOURWEBSITE.com to your URL
(2013-02-01, 11:40 AM)sarisisop Wrote: [ -> ]If you just want a link to the search page try this.
<a href="http://YOURWEBSITE.com/search.php">Search</a>
*Change YOURWEBSITE.com to your URL

@sarisisop - I appreciate the response, but thats not what I'm looking for. I want the result page. I want to tap into the search feature, not just link to it. Thanks though Smile

*Additional info*
One thing I did notice is that the db holds searches and I looked at the code and it does do a db insert that I missed. Would that be what the problem is? Are all searches entered in there, because mine is pretty empty and I swear I've done some searches before...
I havn't had time to investigate this yet, but I should this weekend sometime.

Thanks for reading everyone
Change action to "do_search".

The "results" action grabs from the search cache table. While do_search actually creates that cache.
(2013-02-01, 08:40 PM)labrocca Wrote: [ -> ]Change action to "do_search".

The "results" action grabs from the search cache table. While do_search actually creates that cache.

Exclamation I'm going to try that right now. I'll let you know how I get on.

Thank you very much.



Simply changing the action to do_search in the link above gets me the search page just like linking would.

I opened search.php and saw that the condition is like this:
elseif($mybb->input['action'] == "do_search" && $mybb->request_method == "post")

So is there no way to do this with a link?
How does the search feature work ?

This is a mystery to all users, in truth you have to speak to the elves in the system.

When you enter a search query, the "elves" run all over the forum looking for words that bear no relation to what you have specified, this is in fact an attempt to confuse you and smash the keys on your laptop.

For instance if you input "error in ForumsIcons mod" it will find you every post with the word Error in the title, but, and heres where the elves will really muck you about, it will not display any results pertaining to your exact query.

This action results in you adopting a quizzical look and uttering WTF !!

Mean while the developers on MYBB, who have direct communications links with said elves, are laughing their socks off.

Hope this helps.
In the code you posted, you'll notice that it is looking for "post", so you can't just use a link ("get") the way it is coded. If you don't want to modify the code, you'll have to use a "fake" form.

I think this thread describes what you're looking for:
http://community.mybb.com/thread-131880.html
(2013-02-01, 10:00 PM)Spangle Wrote: [ -> ]
How does the search feature work ?

This is a mystery to all users, in truth you have to speak to the elves in the system.

When you enter a search query, the "elves" run all over the forum looking for words that bear no relation to what you have specified, this is in fact an attempt to confuse you and smash the keys on your laptop.

For instance if you input "error in ForumsIcons mod" it will find you every post with the word Error in the title, but, and heres where the elves will really muck you about, it will not display any results pertaining to your exact query.

This action results in you adopting a quizzical look and uttering WTF !!

Mean while the developers on MYBB, who have direct communications links with said elves, are laughing their socks off.

Hope this helps.

Not really, but it sure made me chuckle. Thanks. Smile

(2013-02-01, 11:09 PM)buzzle Wrote: [ -> ]In the code you posted, you'll notice that it is looking for "post", so you can't just use a link ("get") the way it is coded. If you don't want to modify the code, you'll have to use a "fake" form.

I think this thread describes what you're looking for:
http://community.mybb.com/thread-131880.html

I had a similar 'fake form' thought process going. That thread looks about what I was going for, so I'm going to see what work they already did for me Big Grin

Thanks, that was helpful.
Place your code into a post form then.