Hi,
Untested, but give this a go:
# first work out the category this link is in. If its in multiple cats, we just grab the first one
my $cat_id = $DB->table("CatLinks")->do_query(qq|SELECT CategoryID FROM glinks_CatLinks WHERE LinkID = $_[0]|)->fetchrow || '';
if ($cat_id > 0) {
my $father_id = $DB->table("Category")->select( ['FatherID'], { ID => $cat_id } )->fetchrow || '';
my $sth = $DB->table("Category")->select( { FatherID => $father_id } );
my @cats;
while (my $catid = $sth->fetchrow) {
my $cat = $DB->table('Category')->select( { ID => $catid } )->fetchrow_hashref;
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
push @cats, $cat;
}
}
return { parent_cat_loop => \@cats };
}
Call with:
<%loop parent_cat_loop%>
<a href="<%URL%>"><%Name%></a>
<%endloop%>
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Untested, but give this a go:
Code:
sub { # first work out the category this link is in. If its in multiple cats, we just grab the first one
my $cat_id = $DB->table("CatLinks")->do_query(qq|SELECT CategoryID FROM glinks_CatLinks WHERE LinkID = $_[0]|)->fetchrow || '';
if ($cat_id > 0) {
my $father_id = $DB->table("Category")->select( ['FatherID'], { ID => $cat_id } )->fetchrow || '';
my $sth = $DB->table("Category")->select( { FatherID => $father_id } );
my @cats;
while (my $catid = $sth->fetchrow) {
my $cat = $DB->table('Category')->select( { ID => $catid } )->fetchrow_hashref;
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
push @cats, $cat;
}
}
return { parent_cat_loop => \@cats };
}
Call with:
Code:
<%global_name($ID)%> <%loop parent_cat_loop%>
<a href="<%URL%>"><%Name%></a>
<%endloop%>
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!