Suggest Search
UPDATE files are bundled in an archive.

I was very impressed with the WordPress Suggest plugin and wanted to port it over to MT. The porting was easy but the query was very slow and pulled some bad results from the database. Chad helped me last night and we had almost cleaned it up until v0.2 was released which seems to have fixed the problems I had. Try it using the search form on the sidebar.
This plugin is similar to LiveSearch (and the MT implementation) however the difference is it lets you keep the mt-search.cgi functionality which I liked. Also this plugin works slightly differently to LiveSearch, I prefer this!
Implementing it with MT is very easy, you need to have PHP and be using mySQL as the database, I'm sure this probably works with other SQL based databases but I haven't had the opportunity to try it out. I've so far only managed to get this to work in Internet Explorer and Firefox.
Download suggest.tar.gz and extract the files. In ezsql.php enter your database values as instructed by the comments. These values are exactly the same as the database values entered in mt.cfg and mt-db-pass.cgi. Upload ezsql.php and ac.js to your web server and create a new index template with suggest_search.php (one for every blog you want this enabled)
Next, replace your search form with the following
<form method="get" action="<$MTCGIPath$><$MTSearchScript$>" name="searchform"> <label for="search" accesskey="4">Search: </label><br /><input type="text" name="search" size="20" alt="Search Term"autocomplete="off" /><input type="submit" value="Search" name="subButton"/> </form>
This is just the default search form with some few tweaks (highlighted in red), you can continue to have any of the other options MT offers but what I have pasted above must be present.
Finally right at the bottom of the page, just before the </body> tag, add changing the bits highlighted in red to point to your files.
<script src="http://path.to/ac.js"></script>
<script>InstallAC(document.searchform,document.searchform.search,document.searchform.subButton,"http://www.path.to.com/suggest_search.php","en");</script>
Now when you start typing into the search, it should have drop down list similar to Google Suggest. If you want to tweak the colours in the drop down list, edit the colours found after the commented line
// this function controls background color of marked row ( mozilla + IE )

Peter said:
on Jan 9, 2005 6:03 PM | Reply
I was trying to copy ezsql.phps... not having much luck. If I view source in Safari and then try to copy the source, I end up with lots of extraneous ? marks and other junk. If I try to "wget" the link to ezsql.phps, I get a jumbled file that is impossible to read. Same with suggest_search.phps. Any chance you could bundle all of this source up in a zip/gzip file or some other sort of archive?
Arvind Satyanarayan said:
on Jan 9, 2005 7:14 PM | Reply
Tbe files have been bundled into a gzip file and tutorial updated.
Dan Wolfgang said:
on Jan 9, 2005 7:37 PM | Reply
Ha! Guess what I was working on yesterday? Yep, a suggest feature for the search. What are the odds, huh!?
Abid Omar said:
on Jan 9, 2005 10:49 PM | Reply
Does this use the keywords field to get the search results?
jayseae said:
on Jan 10, 2005 3:27 AM | Reply
No, it actually scans the entire entry text field.
alex said:
on Jan 10, 2005 10:32 PM | Reply
I've installed the script according to the instructions, but FireFox gives me this error in the Javascript console: "uncaught exeption: Permission denied to call method XMLHttpRequest.open". IE gives me a similar, but less detailed error.
Any idea what might be going wrong?
alex said:
on Jan 10, 2005 11:45 PM | Reply
Oh, duh, I figured it out. The script, in combination with browser security, doesn't like mixing domain.com and www.domain.com. The same error occurs on this site, if you start the search from movalog.com, without the www.
Peter said:
on Jan 10, 2005 11:52 PM | Reply
Hrm, is something missing from the end of the script src instructions? Seems like there is a list of args that gets cut off after "document.searchform.subButton,".....
Peter said:
on Jan 10, 2005 11:59 PM | Reply
Also, there are a few parts of your example code that are not valid XHTML 1.1 (though they may be vaild in XHTML 1.0, I haven't checked...):
Are these necessary for your code to work, or can they be altered for XHTML 1.1 compliance?
Peter said:
on Jan 11, 2005 5:12 AM | Reply
Hrm, doesn't seem to be working for me, either in Safari or Firefox on the Mac. I can see that it's trying to fetch the suggest_search.php script each time I enter a letter in the search field, but I never get a dropdown menu. If I hit enter, it performs a plain old search and I do get search results for the word I was typing. Just not any "suggest"-style results.
It's in the sidebar on http://prwdot.org/ under "Search Our Blog", if you want to take a look. I've tried it with and without the non-XHTML-1.1-compliant code, doesn't seem to make a difference.
Arvind Satyanarayan said:
on Jan 11, 2005 6:48 AM | Reply
Peter there seems to be something wrong with your suggest_search.php file. I just tried to query it and it doesn't seem to be able to access the database as I just get a blank page. Make sure that you have correctly uploaded and setup ezsql.php
Peter said:
on Jan 11, 2005 7:13 AM | Reply
Just did a little debugging on this, which you can see if you bring up:
http://prwdot.org/suggest_search.php?hl=en&js=true&qu=apple
Looks like there is some variable $qu which suggestsearch.php expects to be populated by ezsql.php. However, I can't find anything in ezsql.php that refers to a $qu. There is a $query, but no $qu. I added an else statement after the if(!empty($qu)) to catch this condition and echo an error if it occurred. Any idea why $qu might not be populated? I didn't change suggestsearch.php from the version I downloaded, other than adding some debugging code.
Peter said:
on Jan 11, 2005 7:29 AM | Reply
Aha! I think suggestsearch.php was, for some reason, expecting the value of $qu to be pulled from the &qu CGI parameter. For some reason, on my system, this isn't happening. Is this some PHP capability that I don't have enabled? In any case, I added this line to the top of suggestsearch.php:
$qu = $HTTPGETVARS["qu"];
Now it works! Sweet! :-)
VI said:
on Jan 11, 2005 7:55 AM | Reply
Yes peter. registerglobals is what needs to be enabled to make &qu be $qu without $qu = $HTTPGET_VARS["qu"];
Its not recommended to use register_globals as it is a #1 security php hazard.
Peter said:
on Jan 11, 2005 9:06 AM | Reply
Ah, I thought that might be it. I've got registerglobals turned off and most of my other apps can live without it. Perhaps suggestsearch.php should be changed to assume that registerglobals is off. That way, it will work regardless of the registerglobals setting, whereas now it must be on in order for the script to work properly.
Peter said:
on Jan 14, 2005 1:30 AM | Reply
I made a minor tweak to the first SQL query in suggest_search.php. This forces everything to lowercase, which is the way Google's Suggest works, and is the way I prefer it to work. It does cause a slight performance hit, but for me it's negligible. I have posted my version of suggest_search.php, which also incorporates the change I made so that it would work with register_globals set to off.
Get it here
Christian Watson said:
on Feb 7, 2005 9:26 PM | Reply
I don't suppose there's an implementation anywhere that doesn't use PHP? The site I would like to use it on is all ASP.
Ted Tschopp said:
on Mar 16, 2005 2:48 AM | Reply
I just got an implementation working with Perl. I think .NET is next on the list, once all the bugs get squashed.
Ronen said:
on Apr 4, 2005 12:08 PM | Reply
I have used the script and modified the suggest_script to work and it works great. Thanks ;)
My question is : I am using the script in an html form where multiple field have to be filled in. The problem is that when using the suggest_search and the user select his matching suggestion. This operation causes the form to submit, while the user has not yet finished filling in the form.
Is there a way not to let the mouse key or enter key in this field to automatically submit the form.
Thanks, Ronen
sandy said:
on Mar 7, 2007 5:24 PM | Reply
hi,
Thanks for this great script but its not working in IE 6/7. Its working great in FF but in IE its show suggest dropdown but doest not show how many results. Can you please help me its very urgent.
Thanks in advance.
uatzhxes jbdvg said:
on Oct 20, 2008 7:28 AM | Reply
gfsu hwdi nxyoghdl opeamhgl gizco gxsmyarzj tfivx
lgsboqi axzjco said:
on Nov 8, 2008 11:22 AM | Reply
knehr yuefkrdnv anlcdxyt cvauqsbo yupa tjzvg reskh
sale valtrex said:
on Nov 16, 2008 2:13 AM | Reply
zrsguq wtozdx ghrfe