Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [steve04] restricted search shows link in wrong category

Quote Reply
Re: [steve04] restricted search shows link in wrong category In reply to
Hi Steve,

I've found that when GT grabs the categories for building the title_linked that the second category that was added is the one that will show up in the search results.

This happens because the select returns the listing in ascending ID order of the categories found. Then gt scrolls through the list with this code.

my %names = $catlink->select ('LinkID', 'Full_Name', { LinkID => \@ids })->fetchall_list;

So %names would always get the last category it looks at. One way to ensure that you get the Primary category for each link is to rewrite the select statement in search.pm to get better results. I haven't looked into how this works on subcategories of the chosen incoming catid, but with the code below, if you pass in a catid and the link belongs in it, than that category will appear in the title_linked even if it's not the first one, otherwise this will use the first category it comes acrosss instead of the last one like it does by default.

my %names;
my $names_sth = $catlink->select ('CategoryID', 'LinkID', 'Full_Name', { LinkID => \@ids });
while (my $catname = $names_sth->fetchrow_hashref) {
if ($names{$catname->{LinkID}}) {
if ($args->{catid} eq $catname->{CategoryID}) {
$names{$catname->{LinkID}} = $catname->{Full_Name};
}
} else {
$names{$catname->{LinkID}} = $catname->{Full_Name};
}
}


Unfortunately, this change requires editing Links/User/search.pm or it requires that you create a plugin for "query"

Anyway, hope that helps.

peace.
Subject Author Views Date
Thread restricted search shows link in wrong category steve04 1777 Sep 19, 2002, 7:58 AM
Post Re: [steve04] restricted search shows link in wrong category
afinlr 1742 Sep 19, 2002, 8:08 AM
Thread Re: [steve04] restricted search shows link in wrong category
klangan 1660 Oct 16, 2003, 12:13 PM
Post Antwort: [klangan] Re: [steve04] restricted search shows link in wrong category
steve04 1649 Oct 17, 2003, 12:58 AM