Gossamer Forum
Home : Products : Gossamer Links : Discussions :

restricted search shows link in wrong category

Quote Reply
restricted search shows link in wrong category
Hello,

I have some links in multiple categories, for example in cat ID 5 and 20.
Each Category has his own template set.
Search results are grouped.
Detailed option is on.

If I restrict the search to category 5, the results show me the link, which is in category 5 and 20, but the link goes to the entry in category 20. And that's is not good for my purpose.

Can you tell me, what I have to do, so that the search results show me only the entry in category 5, if I restrict the search to this category?

I hope, I could make me understood.

Thank's!

Steven
Quote Reply
Re: [steve04] restricted search shows link in wrong category In reply to
Unfortunately, I don't think this is possible. The link has a group of categories which it is in and when building pages which need category information, it just takes the first one it comes to in the database. I suppose you might be able to pass in a specific category id via the url if you were using a dynamic version but it is not an easy thing to do.

Laura.
The UK High Street
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.
Quote Reply
Antwort: [klangan] Re: [steve04] restricted search shows link in wrong category In reply to
Thank you very much. Sounds good. I will try it soon. But today I will start 10 days of vacancies.

Stephan