Hi,
So you just want to show the users categories they are editors for? If so, this should do the trick (totally untested ;))
get_editors_cats
my $sth = $DB->table("Editors")->select( { Username => $_[0] } ) || die $GT::SQL::error;
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
my $cat_name = $DB->table("Category")->select( ['Full_Name'], { ID => $hit->{CategoryID} } )->fetchrow;
my $cat_url = $CFG->{build_root_url} . "/" . $DB->table("Category")->as_url( $cat_name ) . "/index.html";
push @loop, { %$hit, cat_url => $cat_url, cat_name => $cat_name };
}
my @sorted_cat = sort { $a->{cat_name} cmp $b->{cat_name} } @loop;
return { editor_cat_loop => \@sorted_loop };
}
Call with:
<%get_editors_cats($user)%>
<%if editor_cat_loop%>
<a href="<%cat_url%>"><%cat_name%></a>
<%endloop%>
<%endif%>
It should sort them alphabetically for you too =)
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!
So you just want to show the users categories they are editors for? If so, this should do the trick (totally untested ;))
get_editors_cats
Code:
sub { my $sth = $DB->table("Editors")->select( { Username => $_[0] } ) || die $GT::SQL::error;
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
my $cat_name = $DB->table("Category")->select( ['Full_Name'], { ID => $hit->{CategoryID} } )->fetchrow;
my $cat_url = $CFG->{build_root_url} . "/" . $DB->table("Category")->as_url( $cat_name ) . "/index.html";
push @loop, { %$hit, cat_url => $cat_url, cat_name => $cat_name };
}
my @sorted_cat = sort { $a->{cat_name} cmp $b->{cat_name} } @loop;
return { editor_cat_loop => \@sorted_loop };
}
Call with:
Code:
<%if Status eq "Editor"%> <%get_editors_cats($user)%>
<%if editor_cat_loop%>
<a href="<%cat_url%>"><%cat_name%></a>
<%endloop%>
<%endif%>
It should sort them alphabetically for you too =)
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!