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 }

}

Cheers,
Boris

Facebook, Twitter and Google+ Auth for GLinks and GCommunity | reCAPTCHA for GLinks | Free GLinks Plugins
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
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!