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

[NEW PLUGIN] SearchSuggestions

Quote Reply
[NEW PLUGIN] SearchSuggestions
I was recently asked to write a "search suggestions" plugin for someone, and seeing as I thought it would be beneficial for many other users, I thought I would turn it into a proper plugin :) (and obviously give the client it at the same price Wink)

Here it is:

http://www.ultranerds.co.uk/...rchSuggestions_L287/

It works by letting you either:

1) Use the SearchLogs table (part of the built in GLinks search logging system)
2) Use a custom table (which you pre-fill with the words/phrases you want to come up)

Its $40, but I spent a LONG time working this one out (as I've made it as easy as possible to setup, and also written a nice admin function for managing it).

You can see a copy of it running on my site: http://www.ultranerds.co.uk. Just search for a plugin name, and it will give you some results Smile

Its part of the ULTRA Package and ULTRA Package PRO, so anyone who already owns these can download it from the Members Area now <G>

Please let me know if you have any questions

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,
at the moment the plugin is searching the phrase inside of the words, too.
When I'm searching for Ultra Globals and I'm typing Ult
i see SearchFeed_Results in the results!?!

And it would be better, when a click on one of the suggestions starts the search.
Not only inserting the word into the search form...

I'm already using this form of searching in one of my subpages
http://www.gpaed.de/g-livesearch

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [NEW PLUGIN] SearchSuggestions In reply to
Hi,

Thanks for your suggestions Smile

I've just released version 1.1, which has these changes:

1) You can decide if you want to do "Starts With.." searches, or "Anywhere in string" (i.e using LIKE %$string% or LIKE $string%)
2) Fixed a bug fixes in the admin features with regards to deleting custom words
3) Added in the documentation about how to do "auto submit" when someone selects a work

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

The script does not accept the accentuated characters.

I tested in js file: contentType: "application/x-www-form-urlencoded; charset=iso-8859-1",

...but that does not function.

Do You have a suggestion?

Thanks!

Mick
Quote Reply
Re: [MJ_] [NEW PLUGIN] SearchSuggestions In reply to
Hi,

Weird, that must have got removed from the code somehow. It should work as it is, but in suggest.cgi find:

Code:
my $PCFG = Links::Plugins::get_plugin_user_cfg ('SearchSuggestions');

..and add this below it:

Code:
binmode(STDOUT, ":utf8");

I just tested that on my dev copy, and it shows accents fine Smile

I'll get the released version fixed up

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

It is perfect, corrected problem!

I use the Search Logs table , but is it possible to obtain only the words which have a result higher than 0?

Thanks again!

Mick
Quote Reply
Re: [MJ_] [NEW PLUGIN] SearchSuggestions In reply to
Cool Angelic

To make it only show results where there is more than 1 result, find this in suggest.cgi:

Code:
my $cond;
if ($PCFG->{Type_of_LIKE} eq "in_string") {
$cond = GT::SQL::Condition->new("slog_query","LIKE","%$query%");
} else {
$cond = GT::SQL::Condition->new("slog_query","LIKE","$query%");
}

...and change to:

Code:
my $cond;
if ($PCFG->{Type_of_LIKE} eq "in_string") {
$cond = GT::SQL::Condition->new("slog_query","LIKE","%$query%","slog_hits",">",1);
} else {
$cond = GT::SQL::Condition->new("slog_query","LIKE","$query%","slog_hits",">",1);
}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

If I use a word accentuated (vélo) in the input field (name="query"), the script does not give any result.

Do You think that it is jquery which is at the origin of the problem?

I tested this : <form accept-charset="ISO-8859-1"

...but that does not function.

It is necessary to send the request in UTF-8 ?

Thanks!

Mick

Last edited by:

MJ_: Dec 10, 2011, 8:43 AM
Quote Reply
Re: [MJ_] [NEW PLUGIN] SearchSuggestions In reply to
Hi,

Man, don't you just love UTF8 charachters? Wink I've released v1.2 which should have that bug fixed up (it needed URI escaping in JS, as well as decoding in the suggest.cgi script)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

I made the update, but script does not give a result if I use a word accentuated in the input field.

"velo" gives a result (Snap1.jpg)
whereas "vélo" does not give any result (Snap2.jpg).

Another idea?

Thanks again!

Mick
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

I found the origin.

In js file, I added (escape) : inputString = escape(jQuery(this).val());

That seems to function correctly. :)

Mick

Last edited by:

MJ_: Dec 11, 2011, 3:45 AM
Quote Reply
Re: [MJ_] [NEW PLUGIN] SearchSuggestions In reply to
Hi,

Ah weird, it must not have updated that file. That change was in the new version Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

It is perfect!

A last question.

Is It possible to escape the apostrophe in the results ?
<li onClick="fill('Don\'t do that');">

That causes a Javascript error.

I think that it is in cgi file that it is necessary to intervene on results or query ?

Thanks!

Mick



Quote Reply
Re: [MJ_] [NEW PLUGIN] SearchSuggestions In reply to
Hi,

Man, that was a bit of a sod to fix up! You try "escaping" it using \', but then JS was encoding it, so that never matched!

Anyway, please give the new version (in the Members Area) a go, and let me know if that sorts it for ya (its the same version number, as I couldn't be bothered up update it again Wink)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

I obtain an error:
suggest.cgi: Use of uninitialized value in substitution (s///) at suggest.cgi .
suggest.cgi: Use of uninitialized value in concatenation (.) or string at suggest.cgi.
suggest.cgi: Use of uninitialized value in concatenation (.) or string at suggest.cgi

An idea?

Thanks! :)

Mick

Last edited by:

MJ_: Dec 11, 2011, 7:06 AM
Quote Reply
Re: [MJ_] [NEW PLUGIN] SearchSuggestions In reply to
Mmmm, does it give you a line number?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [NEW PLUGIN] SearchSuggestions In reply to
Hi Andy,

I modified :
$hit->{suggestion_query} = GT::CGI::html_escape($hit->{suggestion_query});

with :
$hit->{suggestion_query} = GT::CGI::html_escape($hit->{slog_query});

...and that functions now!

Very great job, Andy! :)

Mick
Quote Reply
Re: [MJ_] [NEW PLUGIN] SearchSuggestions In reply to
Whoops, I've fixed that up now Blush Serves me right working 7 day weeks ;)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates