Gossamer Forum
Quote Reply
list of subcategory
How can I display a list off all subcategory of specific category?
Quote Reply
Re: [nir] list of subcategory In reply to
Is this just gonna be something hard-coded onto a page? If so - something like this should work:

Category :

Test
Test/1
Test/2
Test/3

Testing 2
Testing 2/Bla
Testing 2/Bla 2


Homepage

..and show (for example)

Testing 2
Testing 2/Bla
Testing 2/Bla 2

..is that what your after?

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
Quote Reply
Re: [Andy] list of subcategory In reply to
Hi Andy

Its need to be something like
Cat name 1
Cat name 2

I mean I just need to display the names of the subcategory and the link to the category page.
Quote Reply
Re: [nir] list of subcategory In reply to
Hi,

Still not 100% sure what your asking for - but try this:

get_categorys_by_id
Code:
sub {

my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;

my $tbl = $DB->table('Category');
$tbl->select_options ('ORDER Full_Name');

my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
my $sth = $tbl->select ( $cond ) || die $GT::SQL::error;

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

return { cat_loop => \@cats }

}

Code:
<%get_categorys_by_id(1234)%>
<ul>
<%loop cat_loop%>
<il><a href="<%Name%>"><%Name%></a></li>
<%endloop%>
</ul>

(change "1234" to the category ID you want to get)

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
Quote Reply
Re: [Andy] list of subcategory In reply to
Thanks,

There was a small bug I change it and now it work
One thing – Not it display the category and the subcategory, his there a way that it will not display the category. I mean if I use <%get_categorys_by_id(2)%>
That it will display the subcategory of "2" but not the "2" itself

sub { my $cat = shift; my $all_ids = $DB->table('Category')->children($cat); push @$all_ids, $cat; my $tbl = $DB->table('Category'); $tbl->select_options ('ORDER BY Full_Name'); my $cond = GT::SQL::Condition->new('ID', 'IN', $all_ids); my $sth = $tbl->select ( $cond ) || die $GT::SQL::error; my @cats; while (my $hit = $sth->fetchrow_hashref) { $hit->{URL} = $CFG->{build_root_url} . $tbl->as_url($hit->{Full_Name}) . '/' . $CFG->{build_index}; push @cats, $hit; } return { cat_loop => \@cats } }
Quote Reply
Re: [nir] list of subcategory In reply to
Cool - just delete:

Code:
push @$all_ids, $cat;

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
Quote Reply
Re: [Andy] list of subcategory In reply to
ThanksCool