Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Suggest query (as in Google Suggest)

(Page 3 of 3)
> >
Quote Reply
Re: [pugdog] Suggest query (as in Google Suggest) In reply to
Here is my working code: (red marked is for 3.0x)

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: Ivan Herger <info@iyengar-yoga.com>
# | Adpted to GLinks 3.x by John Gotze <john@slashdemocracy.org |
# +----------------------------------------------------------------------+

use strict;
use lib '/home/cgi-bin/admin';
use Links qw/$CFG $DB $IN/;

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/home/cgi-bin/admin');

main();

sub main {
my $t = $DB->table('SearchLogs');
$t->select_options('ORDER by slog_hits DESC', 'LIMIT 10');
my $q = $IN->param('query');
my $cond = GT::SQL::Condition->new( 'slog_query', 'LIKE', "$q%");

my $sth = $t->select($cond);
my $base = 'http://slashdemocracy.org/cgi-bin/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 onmouseover="liveSearchHover(this)" onclick="liveSearchClicked(this)"><a href="$base=$result->{slog_query}" name="$result->{slog_query}">$result->{slog_query}</a> <span style="color:green;overflow:hidden;">$result->{slog_hits} results</span></li>\n|;
}
print qq|</ul>|;
}
}

HTH
John
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
slog_hits was the missing piece of the puzzle :) Thanks so much for the help.
Quote Reply
Re: [fantasyman] Suggest query (as in Google Suggest) In reply to
Everything works fine here, too. Thanks everyone!
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
Hello

Which search logger plug in are you using


This does not work with GT plug in? is there another one?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Suggest query (as in Google Suggest) In reply to
The search logger is built into recent versions of GLinks, and that's what I'm using.
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
Thank you..
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
Heya all,

Has anyone tried changing this so the "suggestions" are not built from your search logs, but from the titles of your links?

That is, as you type a word the dropdown shows you all links with the word/phrase in the title of the link.

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Suggest query (as in Google Suggest) In reply to
Yes, see http://slashdemocracy.org/links/

Just change the table you use.
Quote Reply
Re: [sangiro] Suggest query (as in Google Suggest) In reply to
I use the Table Links_Word_List for my search example
http://www.download-tipp.de/livesearch/

my $t = $DB->table('Links_Word_List');
......
snip
......
print qq|<li class="LSRow" onmouseover="liveSearchHover(this)" onclick="liveSearchClicked(this)"> <a href="$base=$result->{Word}" name="$result->{Word}">$result->{Word}</a></li>\n|;
.....

So you can use also the table Links with the field Title.
You should change it like the example above.
Links_Word_List should be Links
and Word should be Title

Best regards from
Bremen/Germany

Lothar
Quote Reply
Re: [eljot] Suggest query (as in Google Suggest) In reply to
Excellent. Thank you - I'll take a look at that. Smile

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Suggest query (as in Google Suggest) In reply to
Hmm, works nearly perfect, but I have problems with nonenglish charakters!
A search for "kö" just suggests "k?rper", but in my admin searchlogs nonenglish charakters are shown without any problem. So it should be no problem on this.
Do you have any suggestions how to solve this problem?
Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [gotze] Suggest query (as in Google Suggest) In reply to
So has anyone tried to make plugin from this? I see Google is using it now so it would be cool to have something like this as plugin.

Andy? Wink

Regards.

UnReal Network
Quote Reply
Re: [DeadMan] Suggest query (as in Google Suggest) In reply to
Anyone has working plugin/global for this 'Suggest Query' feature?

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Suggest query (as in Google Suggest) In reply to
This one seems 2 work:

http://www.2muslims.com/...earch/new_page_3.htm

I had problems with the "access denied" part of the java on mine, so you can try this script if you use a direct url...

This site uses the same script to the extreme:

http://1976design.com/blog/

hope this helps,

- Jonathan

Last edited by:

jdgamble: Jun 6, 2009, 2:45 PM
Quote Reply
Re: [DeadMan] Suggest query (as in Google Suggest) In reply to
Mine is working fine, except for nonenglish characters...
http://www.gpaed.de/g-livesearch

Any help for nonenglish characters would be great...
Thanks

Matthias
gpaed.de
Quote Reply
Suggest query (as in Google Suggest) In reply to
Thanks for both the example, I will check it out and let you know how it works - this is a very good feature.

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] Suggest query (as in Google Suggest) In reply to
I saw that in firefox when you use the arrows to go over the suggestions, it doesn't go pass the first one.

In explorer, when you go with arrow keys from bottom to top the system shows in the search box the query that you stand on with the arrow. But when you go from top to bottom it doesn't do that.
is there a solution to make it work in both directions and also in firefox?
Quote Reply
Re: [Matthias70] Suggest query (as in Google Suggest) In reply to
Hi Matthias,

Your request is old. But, if you still seek a solution, you can test this in livesearch.cgi file :

print "Content-Type: text/xml; charset=\"ISO-8859-1\"\n\n";

Mick
Quote Reply
Re: [MJ_] Suggest query (as in Google Suggest) In reply to
Hi MJ,
thanks a lot for your help!
It works perfect Smile

Matthias
gpaed.de
> >