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.
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.