Gossamer Forum
Home : Products : Gossamer Links : Discussions :

List Main Categories on every page

Quote Reply
List Main Categories on every page
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.
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
Quote Reply
Re: [Andy] List Main Categories on every page In reply to
Thank you, but got this error: A fatal error has occured:


GT::SQL::Table (27475): Unknown method 'fetchrow_hashef' called at (eval 21) line 6.
Please enable debugging in setup for more details.
Quote Reply
Re: [shimmy1] List Main Categories on every page In reply to
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!
Quote Reply
Re: [Andy] List Main Categories on every page In reply to
You are a genius Sir. I thank you!