Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [shimmy1] List Main Categories on every page

Quote Reply
Re: [shimmy1] List Main Categories on every page In reply to
Hi,

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!

Last edited by:

Andy: Jul 16, 2013, 6:00 AM
Subject Author Views Date
Thread List Main Categories on every page shimmy1 5987 Jul 15, 2013, 12:13 PM
Thread Re: [shimmy1] List Main Categories on every page
Andy 5678 Jul 16, 2013, 1:52 AM
Thread Re: [Andy] List Main Categories on every page
shimmy1 5657 Jul 16, 2013, 5:58 AM
Thread Re: [shimmy1] List Main Categories on every page
Andy 5650 Jul 16, 2013, 6:00 AM
Post Re: [Andy] List Main Categories on every page
shimmy1 5643 Jul 16, 2013, 6:18 AM