Small error there: You missed an = in the code. This works for me:
my $LinkID = $_[0];
my $sth = $DB->table("CatLinks")->select( ['CategoryID'], { LinkID => $LinkID });
my (@cat_ids,@cats);
while (my $cat_id = $sth->fetchrow) {
push @cat_ids, $cat_id
}
my $Category = $DB->table("Category");
$Category->select_options("ORDER BY Name DESC");
my $sth_cats = $Category->select( GT::SQL::Condition->new('ID','IN',\@cat_ids) );
while (my $cat = $sth_cats->fetchrow_hashref) {
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
push @cats, $cat;
}
return { cats_in_loop => \@cats }
}
Code:
sub { my $LinkID = $_[0];
my $sth = $DB->table("CatLinks")->select( ['CategoryID'], { LinkID => $LinkID });
my (@cat_ids,@cats);
while (my $cat_id = $sth->fetchrow) {
push @cat_ids, $cat_id
}
my $Category = $DB->table("Category");
$Category->select_options("ORDER BY Name DESC");
my $sth_cats = $Category->select( GT::SQL::Condition->new('ID','IN',\@cat_ids) );
while (my $cat = $sth_cats->fetchrow_hashref) {
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
push @cats, $cat;
}
return { cats_in_loop => \@cats }
}