Gossamer Forum
Home : Products : Gossamer Links : Discussions :

highlight query word in search result?

Quote Reply
highlight query word in search result?
What's the easiest way to highlight the query words in search results? In title and description?
Quote Reply
Re: [flybuzz] highlight query word in search result? In reply to
bolding one of the options in the setup section.

look under something like..

Admin > Setup > Search Options

and I think you'll find it there.

r
Quote Reply
Re: [ryel01] highlight query word in search result? In reply to
No, not just bold I need "highlight" and any color I want to.
Quote Reply
Re: [flybuzz] highlight query word in search result? In reply to
Sounds like a pretty sool plugin. "Search Highlighter" (similar to the way GForum does it).

I'll add it to my list... but can't guarantee any time for a release :(

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 | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] highlight query word in search result? In reply to
Just let me know what file to open and what code to change please... It's not too hard is it? Unimpressed
Quote Reply
Re: [flybuzz] highlight query word in search result? In reply to
without looking probably search.pm or something like that?

r
Quote Reply
Re: [ryel01] highlight query word in search result? In reply to
I have seen it done in many sites, my last try. Anyone??? Unsure
Quote Reply
Re: [flybuzz] highlight query word in search result? In reply to
Quote:
It's not too hard is it?

It is if your not a programmer. As I said in my last post; I'll try and get something made up... but I can't guarantee anything, as its a pretty busy time of year.

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 | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [flybuzz] highlight query word in search result? In reply to
I kinda figurered out reading one of the old post...
Quote Reply
Re: [flybuzz] highlight query word in search result? In reply to
In Reply To:
I kinda figurered out reading one of the old post...

heheh.

I'm off for the night now. Just before I leave though, I'll post this URL;

Keyword_Highlighter: http://www.ultranerds.com/...bin/details/122.html

It should all work (I've tested it on a couple of my sites), and there is even documentation :)

Give it a go if you want.

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 | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] highlight query word in search result? In reply to
Thanks for the plugin, whenever you wake up, can you let me know where's the place to change the highlight color? I will go look around myself just in case I don't find it. Appreciate all your help! Smile
Quote Reply
Re: [flybuzz] highlight query word in search result? In reply to
No prob. If you want to hardcode the colors, you will need to edit /admin/Plugins/Keyword_Highlighter.pm

Find;

Code:
# define our random color.
my @colors = map {
join "", map { sprintf "%02x", rand(255) } (0..2)
} (0..1);

...and replace with;

Code:
my @colors;
push @colors, 'FFFFFF';
push @colors, 'FF99FF';
push @colors, 'BBAA99';

Please note; you will need to change the colors to whatever color you want to use :)

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 | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] highlight query word in search result? In reply to
Andy,

On my site, it highlights the keywords only in the Description field. How do you get it to highlight the keyword if contained in the Category and Title fields?

Thanks.

mgeyman
Quote Reply
Re: [mgeyman] highlight query word in search result? In reply to
Hi. You need to just pass the other validables through the plugin. i.e;

change;

$Description

...to;

$Title

...or $VarName

$VarName can be the value of *ANY* tags thats available to you in the current template.

Hope that helps.

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 | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] highlight query word in search result? In reply to
It sure does. Thanks a lot for your help!!

mgeyman
Quote Reply
Re: [Andy] highlight query word in search result? In reply to
Hi Andy I just tried these out :

# define our random color.
my @colors;
push @colors, 'FF66FF';
push @colors, '6699FF';
push @colors, '66FFFF';
push @colors, 'CC99FF';
push @colors, 'FFFF66';
push @colors, 'FF9933';

but it only displays "FF66FF" as a color for each word that is displayed in each description. Ie before modifying the code there was a different color for each link that was displayed description 1, color 1, / description 2, color 2 etc. whereas with this mod there is description 1, color 1 / description 2, color 1 etc.

Any ideas to get the other colors to pick up after the first one... ?

Thanks for the plug-in nice new function !

John
Significant Media
Quote Reply
Re: [Jag] highlight query word in search result? In reply to
Hi. Sorry about that. Looks like you hit a bug =)

Changing the code inside the foreach () { } button to;

Code:
# define our random color.
my @colors;
push @colors, 'FF66FF';
push @colors, '6699FF';
push @colors, '66FFFF';
push @colors, 'CC99FF';
push @colors, 'FFFF66';
push @colors, 'FF9933';

my $rand_number = rand $#colors;

# now lets make the pretty colours!
my $highlight_string = qq|style="background-color: #| . $colors[$rand_number] . q|"|;
my $replace = qq|<span $highlight_string>$_</span>|;
$value =~ s|\Q$_|$replace|ig;

...should make it so that multiple random colors are used :)

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 | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!