Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [biglion] Displaying Multiple Categories for a Link

Quote Reply
Re: [biglion] Displaying Multiple Categories for a Link In reply to
Hi,

Try this:

Code:
sub {

my $sth = $DB->table('CatLinks')->select ( { LinkID => $_[0] }, ['CategoryID'] ) || die $GT::SQL::error;

my @cats;
while (my $hit = $sth->fetchrow_hashref) {

# print $hit->{LinkID} . "<br/>";

my $cat = $DB->table('Category')->select( { ID => $hit->{CategoryID} } )->fetchrow_hashref;
my $cat_url = $DB->table('Category')->as_url( $cat->{Full_Name} );
my $tmp;
$tmp->{Name} = $cat->{Name};
$tmp->{URL} = $CFG->{build_root_url} . "/" . $cat_url . "/" . $CFG->{build_index};
push @cats, $tmp;
}

return { cats_in => \@cats };
}

..and then this template code:

Code:
<%get_cats_in($ID)%>
<ul>
<%loop cats_in%>
<li><a href="<%URL%>"><%Name%></a></li>
<%endloop%>
</ul>

Tested that on our dev install, and all seems to work :)

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!
Subject Author Views Date
Thread Displaying Multiple Categories for a Link biglion 3537 Aug 23, 2007, 1:51 PM
Thread Re: [biglion] Displaying Multiple Categories for a Link
Andy 3441 Aug 24, 2007, 1:55 AM
Thread Re: [Andy] Displaying Multiple Categories for a Link
biglion 3447 Aug 24, 2007, 7:59 AM
Thread Re: [biglion] Displaying Multiple Categories for a Link
Andy 3433 Aug 24, 2007, 8:09 AM
Thread Re: [Andy] Displaying Multiple Categories for a Link
biglion 3413 Aug 24, 2007, 8:37 AM
Thread Re: [biglion] Displaying Multiple Categories for a Link
Andy 3428 Aug 24, 2007, 8:55 AM
Post Re: [Andy] Displaying Multiple Categories for a Link
biglion 3430 Aug 24, 2007, 9:01 AM