I decided not to write a plugin, but simply post all the relevant files here. It works, but the CSS is not perfect yet. If there are any CSS gurus out there, how can make it more Google like, I'd be happy to know!
The LiveSearch feature makes use of the SearchLogger plugin to generate the list, so you need to have this plugin installed, and it should contain a reasonable number of entries for the LiveSearch feature to make sense.
xhtml code http://www.iyengar-yoga.com/livesearch.html JavaScript code http://www.iyengar-yoga.com/inc/livesearch.js CSS stylesheet http://www.iyengar-yoga.com/inc/livesearch.css Perl Code Code:
#!/usr/bin/perl
# +----------------------------------------------------------------------+
# | Copyright (c) 2004 Iyengar Yoga Resources |
# +----------------------------------------------------------------------+
# | Licensed under the Apache License, Version 2.0 (the "License"); |
# | you may not use this file except in compliance with the License. |
# | You may obtain a copy of the License at |
# | http://www.apache.org/licenses/LICENSE-2.0 |
# | Unless required by applicable law or agreed to in writing, software |
# | distributed under the License is distributed on an "AS IS" BASIS, |
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
# | implied. See the License for the specific language governing |
# | permissions and limitations under the License. |
# +----------------------------------------------------------------------+
# | Author: yogi <info@iyengar-yoga.com> |
# +----------------------------------------------------------------------+
use strict;
use lib '/path/to/links/admin';
use Links qw/$CFG $DB $IN/;
local $SIG{__DIE__} = \&Links::fatal;
Links::init('/path/to/links/admin');
main();
sub main {
my $t = $DB->table('SearchLog');
$t->select_options('ORDER by HitCount DESC', 'LIMIT 10');
my $q = $IN->param('query');
my $cond = GT::SQL::Condition->new( 'Term', 'LIKE', "$q%");
my $sth = $t->select($cond);
my $base = 'http://www.iyengar-yoga.com/perl/directory/search.cgi?query';
print "Content-Type: text/xml\n\n";
if ($t->hits) {
print qq|<ul class="LSRes">|;
while (my $result = $sth->fetchrow_hashref) {
print qq|<li class="LSRow" onmouseover="liveSearchHover(this)" onclick="liveSearchClicked(this)"><a href="$base=$result->{Term}" name="$result->{Term}">$result->{Term}</a> <span style="color:green;overflow:hidden;">$result->{Results} results</span></li>\n|;
}
print qq|</ul>|;
}
}
Background infos on the method used, plus maybe some tips for installation:
http://blog4.bitflux.ch/wiki/LiveSearch Enjoy!
Ivan
-----
Iyengar Yoga Resources /
GT Plugins