Can i modify the category tag to make it work on every page instead of just the homepage? I would like to list the Main Categories in the sidebar of every page.
Jul 16, 2013, 1:52 AM
Veteran / Moderator (18441 posts)
Jul 16, 2013, 1:52 AM
Post #2 of 5
Views: 5514
Hi,
Untested, but something like this should do the trick:
get_top_cats
my @loop;
my $Category = $DB->table("Category");
$Category->select_options("ORDER BY Name");
my $sth = $Category->select( { FatherID => 0 } );
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = $CFG->{build_root_url} . "/" . $Category->as_url( $cat->{Full_Name} ) . "/";
push @loop, $cat;
}
return { top_cat_loop => \@loop }
}
Call with:
<%loop top_cat_loop%>
<a href="<%URL%>"><%Name%></a><br />
<%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 something like this should do the trick:
get_top_cats
Code:
sub { my @loop;
my $Category = $DB->table("Category");
$Category->select_options("ORDER BY Name");
my $sth = $Category->select( { FatherID => 0 } );
while (my $cat = $sth->fetchrow_hashref) {
$cat->{URL} = $CFG->{build_root_url} . "/" . $Category->as_url( $cat->{Full_Name} ) . "/";
push @loop, $cat;
}
return { top_cat_loop => \@loop }
}
Call with:
Code:
<%get_top_cats%> <%loop top_cat_loop%>
<a href="<%URL%>"><%Name%></a><br />
<%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!
Jul 16, 2013, 6:00 AM
Veteran / Moderator (18441 posts)
Jul 16, 2013, 6:00 AM
Post #4 of 5
Views: 5486
Oops, was a typo - please try the modified version above.
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!
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!