Gossamer Forum
Quote Reply
List of sub categoris
Hello

I know we have done this before but i can nopt find it..

How can we pull a list of all Sub categories of a given category using the Father category ID?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] List of sub categoris In reply to
Mmmm try this global, works perfect for me.

Code:
sub {
my $cat = shift;
my $db_obj = $DB->table('Category');
$db_obj->select_options ('ORDER BY Full_Name DESC');
my $cond = GT::SQL::Condition->new('FatherID', '=', $cat);
my $sth = $db_obj->select ( $cond) || die $GT::SQL::error;

my @cats;
while (my $hit = $sth->fetchrow_hashref) {
$hit->{URL} = $CFG->{build_root_url} . '/' . $DB->table('Category')->as_url( $hit->{Full_Name} ) . '/' . $CFG->{build_index};
push @cats, $hit;
}

return { cat_loop => \@cats }

}

rgrdz
Boris
Quote Reply
Re: [eupos] List of sub categoris In reply to
Thank you

We we want is to display the sub categories outside that category by specifying its ID like this...

<%:All_Subs_In_Category($ID)%>
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] List of sub categoris In reply to
That should work fine for that.

Name the global "All_Subs_In_Category", then in your template call with:

Code:
<%All_Subs_In_Category($ID)%>
<%if cat_loop.length%>
<%loop cat_loop%>
<%include subcategory.html%> <br />
<%endloop%>
<%endif%>

Should do the trick.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates