Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Link only LAST category in search results

Quote Reply
Link only LAST category in search results
Hi,

I'd like to link only the LAST category in the search results, e.g.;

Shopping and Services > Outdoors > Boating > Services

I know it's done at ... sub search_build_linked_title in search.cgi ... but I'm not sure how to link only the last one, as opposed to all of them - any hints?


All the best
Shaun

Quote Reply
Re: Link only LAST category in search results In reply to
Yes ... got it working !!!

Sometimes its the little things that make you happy Smile

Quote Reply
Re: Link only LAST category in search results In reply to
Hi,

Could you post how you accomplished this?
I think everyone could benefit from this one. Smile

Thanks again.

Robert Blackstone
Webmaster of Scato Search
http://www.scato.com
Quote Reply
Re: Link only LAST category in search results In reply to
Hi Robert,

Its not a particularly tidy or well coded mod, I couldn't get it to work the way I had originally planned, but here it is:

Look for this in search.cgi

Code:
sub search_build_linked_title {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.
#
my $input = shift;
my (@dirs, $dir, $output, $path);

@dirs = split (/\//, $input);
for (0 .. $#dirs) {
$path = "/" . &build_clean_name( join "/", @dirs[0 .. $_] );
$output .= qq| <A HREF="$LINKS{build_root_url}$path/">$dirs[$_]</A> >|;
}
chop $output;
return $output;
}
Replace with this:

Code:
sub search_build_linked_title {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.
#
my $input = shift;
my (@dirs, $dir, $output, $path, $last);

@dirs = split (/\//, $input);
$last = &search_build_linked_title_last(pop @dirs);

for (0 .. $#dirs) {
$path = "/" . &build_clean_name( join "/", @dirs[0 .. $_] );
$output .= qq| $dirs[$_] >|; ## Remove URL from higher level cats
}

$output .= qq| <A HREF="$LINKS{build_root_url}$path$last</A> |; ## Add URL link to last cat

return $output;
}


sub search_build_linked_title_last {
# --------------------------------------------------------
# Returns a string of the last category
#
my $input = shift;
my (@dirs, $path);

@dirs = split (/\//, $input);

$path = "/" . &build_clean_name( join "/", @dirs[0 .. $_] ); ## Build usable dir name for last cat only
$input = qq|$path/">$dirs[$_]|; ## Add last cat path and name to pass back

return $input;
}
If anyone can post an improved version or give me guidance on a better way of coding it, please let me know.

All the best
Shaun