Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Highlight Bug?

Quote Reply
Highlight Bug?
Hi, I found another peculiarity when users are searching.

I have the highlight search terms turned on. I notice it is not just the title and decsciption which get highlighted, but also the information line (hits, votes etc) and the hyperlinks after it (Rate It etc).

The Hepatitis Information Network new
Interactively learning about hepatitis is a big part of what makes HepNet so unique.
(Added: Thu Apr 18 2002 Hits: 0 Rating: Votes: 0) Rate It Review It


This searchers query was "Hepatitis A".

I wonder if this is in fact a bug, or it is meant to be this way? Is there a way I can get it to highlight just the Title and Description?

Quote Reply
Re: [sooke] Highlight Bug? In reply to
This one has been bugging me for a while. I'm sure there's an easy fix. I haven't had time to nose around the code for it yet.

Sean
Quote Reply
Re: [SeanP] Highlight Bug? In reply to
I was beginning to think I was the only one! Not that I am glad its a problem for you, I am still a little too novice to work this one out. I think, more important than it being a problem for us, it is irritating for the searcher! The highlights in the title and around the page, distract from the purpose of highlighting the important parts of the description. At the very least, there should be no highlighting for the non-link items, like Rate, Review, Hits.

Unimpressed
Quote Reply
Re: [sooke] Highlight Bug? In reply to
Here's the code that highlights the words and prints the results:

Code:
# If we are bolding the results, let's bold them.
if ($CFG->{search_bold}) {
my $tempquery = $args->{query};
$tempquery =~ s/[+\-"']//g;
my @terms = split /\s/, $tempquery;
foreach my $term (@terms) {
next unless ($term);
$term =~ s/^\s*|\s*$//;
if ($term =~ s/(.+)\*(.*)/$1/) {
push @terms, $2 if ($2);
$term = $1;
}
$link_results =~ s,(<[^>]+>)|(\Q$term\E),defined($1) ? $1 : "<B>$2</B>",gie if ($link_results);
$category_results =~ s,(<[^>]+>)|(\Q$term\E),defined($1) ? $1 : "<B>$2</B>",gie if ($category_results);
}
}

# Print the output.
my $results = {
link_results => $link_results,
link_results_loop => \@link_results_loop,
category_results => $category_results,
category_results_loop => \@category_results_loop,
link_hits => $link_count,
cat_hits => $cat_count,
next => $toolbar,
term => $term
};
return $results;
}

I guess within the link_results, it should only bold for <%Title%>, <%Description%>, and <%URL%>.

If I was a better perl programmer, I could probably fix it. Maybe one of the perl gurus out there can make heads or tails of it. Wink

Sean

Last edited by:

SeanP: Apr 23, 2002, 9:20 PM
Quote Reply
Re: [SeanP] Highlight Bug? In reply to
   

Quote:


I guess within the link_results, it should only bold for <%Title%>, <%Description%>, and <%URL%>.


I agree. I was thinking even just <%Title%> and <%Description%>.... to make my results look as clean as possible and maximum attention to the highlighted parts in the description. In any case, I am sure it is much the same modification....... hopefully one of our perl gurus will take a bit at this

Smile
Quote Reply
Re: [sooke] Highlight Bug? In reply to
Ah, you're right. I added the URL and category lines:
  • Cisco Systems
    Cisco (CSCO) is the leading supplier of networking equipment & network management for the Internet. Products include routers, hubs, ethernet, LAN/ATM switches, dial-up access servers and software.
    (Added: Mon Apr 01 2002 Hits: 0 Rating: 0.00 Votes: 0) Rate It Review It
    Category: Computers/Data Communications/Vendors/Manufacturers
    http://www.cisco.com/

[/url]

Quote Reply
Re: [SeanP] Highlight Bug? In reply to
The Category line really looks bad with highlighting in it.

I had a searcher actually ask me why the Rate It looks funny? he/she was referring to the highlighted 'a' in Rate it of course.
Quote Reply
Re: [SeanP] Highlight Bug? In reply to
Any experts out there who are finding this annoying want to have a stab at a mod/fix for the highlighting??

I think Sean and I are hoping for highlighting on just <%title%> <%description%> and perhaps <%url%>, please correct me if I am wrong Sean.
Quote Reply
Re: [sooke] Highlight Bug? In reply to
Currently the way it is done is that the output from link.html is built up and then the regex is made to bold the search terms. Its not easy to get around this without altering the order in which the output is built or the position of the regex.

In Links/User/Search.pm there's a loop called:

foreach my $cat (sort keys %link_output) {

....you'd need to put the regex inside it rather than below it where it currently is, but also make a couple of changes to the bolding code..

I'm sure there are a few different ways to do it...its not tricky but would probably take a bit of trial and error.

Last edited by:

Paul: Apr 30, 2002, 9:43 AM
Quote Reply
Re: [Paul] Highlight Bug? In reply to
You could even add markers to your template to tell it what to highlight. Something like:

Code:
<!-- Bold ON -->

whatever you want bolded here...

<!-- Bold OFF -->

and then just have the highlight function look for those tags and highlight in between. Would that work?

Sean
Quote Reply
Re: [SeanP] Highlight Bug? In reply to
I don't think it is a good idea.
We should not make slower the template system with such feature. The problem could be solved as Paul suggested within the foreach cycle.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...