Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category Name in Search Results

Quote Reply
Category Name in Search Results
I have a lot of categories, and it sometimes makes things complex in the search results.

Is there anyway to add a field to the category database called "Simple_Name" and then have it display in the category results as a link to the category without the full path?

In other words, rather than having the categories come up as follows in the search results:


Top : Category : Subcategory : Subcategory : Name

I would like them to come up:

Easy_Name

I can create the new category field, but can't find the file and place where I would make these adjustments so that it is displayed in the search results with a link to the category. Any help would be much appreciated!

-jw

Quote Reply
Re: [jwalter] Category Name in Search Results In reply to
Hi,

I think what you need is on about line 130-140 of Links/User/Search.pm

Code:
# Now format the category results.
my $count = 0;
my ($category_results, @category_results_loop);
if (!$filter and $cat_count) {
while (my $cat = $cat_sth->fetchrow_hashref) {
last if ($count++ > $args->{mh});
my $title = Links::Build::build ('title_linked', { name => $cat->{Full_Name}, complete => 1 });
$category_results .= "<li>$title\n";
$cat->{title_linked} = $title;
push @category_results_loop, $cat;
}
}

Don't quote me but it may work if you change it to:

Code:
# Now format the category results.
my $count = 0;
my ($category_results, @category_results_loop);
if (!$filter and $cat_count) {
while (my $cat = $cat_sth->fetchrow_hashref) {
last if ($count++ > $args->{mh});
my $title = $cat->{Simple_Name};
$category_results .= "<li>$title\n";
$cat->{title_linked} = $title;
push @category_results_loop, $cat;
}

}





Last edited by:

PaulW: Dec 10, 2001, 12:04 PM
Quote Reply
Re: [PaulW] Category Name in Search Results In reply to
Thanks!

I tried the code, and it did put in the "Simple_Name" field, the only problem was that it wasn't linked to the actual category. It just wrote out the name without a link back to the category. I've been trying to change the code to make it link to the category with no luck so far. If anyone has any ideas or insights that would be great...

-jw
Quote Reply
Re: [jwalter] Category Name in Search Results In reply to
You just need to alter this bit:

my $title = $cat->{Simple_Name};

...to hyperlink...eg...

my $title = qq|<a href="$CFG->{build_root_url}/$cat->{Full_Name}">$cat->{Simple_Name}</a>|;

I'm not sure that URL is correct but you get the idea.
Quote Reply
Re: [PaulW] Category Name in Search Results In reply to
Beautiful!

Thanks very much for the detailed help. I got it to work now, and it's doing exactly what I had envisioned. Smile

-jw
Quote Reply
Re: [jwalter] Category Name in Search Results In reply to
Great!