How can I display a list off all subcategory of specific category?
Jul 24, 2008, 4:50 AM
Veteran / Moderator (17297 posts)
Jul 24, 2008, 4:50 AM
Post #2 of 7
Views: 467
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
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
Jul 24, 2008, 5:54 AM
Veteran / Moderator (17297 posts)
Jul 24, 2008, 5:54 AM
Post #4 of 7
Views: 463
Hi,
Still not 100% sure what your asking for - but try this:
get_categorys_by_id
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 }
}
<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
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
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 } }
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 } }
Jul 24, 2008, 6:41 AM
Veteran / Moderator (17297 posts)
Jul 24, 2008, 6:41 AM
Post #6 of 7
Views: 457
Cool - just delete:
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
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

