Home : Products : Gossamer Links : Development, Plugins and Globals :

Products: Gossamer Links: Development, Plugins and Globals: Re: [nir] related categories links: Edit Log

Here is the list of edits for this post
Re: [nir] related categories links
Glad it worked. To get a list of the categories that are related to the current category, you would do something like (untested)

work_out_related_cats
Code:
sub {
my $cat_id = $_[0];

my $sth = $DB->table("CatRelations")->select( { CategoryID => $cat_id } );
my @related_cats;
while (my $hit = $sth->fetchrow_hashref) {
my $cat = $DB->table('Category')->select( { ID => $hit->{RelationID} } )->fetchrow_hashref;
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
if (length $hit->{RelationName} > 0) {
$cat->{Name} = $hit->{RelationName};
}
push @related_cats, $cat;
}

return { related_cat_loop => \@related_cats };
}

Then in category.html:

Code:
<%work_out_related_cats($ID)%>
<%if related_cat_loop.length%>
<%loop related_cat_loop%>
<a href="<%URL%>"><%Name%></a> <br />
<%endloop%>
<%endif%>

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: Aug 5, 2009, 2:43 AM

Edit Log: