How can I use a global that will return list of categories that are its subcategory and the sub sub category up to the end
Oct 28, 2008, 8:57 AM
Veteran / Moderator (17298 posts)
Oct 28, 2008, 8:57 AM
Post #2 of 7
Views: 581
Hi,
Do you mean you want a global, which would for example:
1) Top Cat
2) Top Cat/Test
3) Top Cat/Test 2
4) Top Cat/Test 2/Sub Cat
5) Top Cat/Test 2/Sub Cat/Another Cat
6) Top Cat/Test 3
...and you wanna get the category "2", and all its sub-categories?
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
Do you mean you want a global, which would for example:
1) Top Cat
2) Top Cat/Test
3) Top Cat/Test 2
4) Top Cat/Test 2/Sub Cat
5) Top Cat/Test 2/Sub Cat/Another Cat
6) Top Cat/Test 3
...and you wanna get the category "2", and all its sub-categories?
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
Oct 28, 2008, 9:07 AM
Veteran / Moderator (17298 posts)
Oct 28, 2008, 9:07 AM
Post #3 of 7
Views: 580
Hi,
Try this global:
get_cats_from_this_cat
my $cat = $_[0];
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $db_obj = $DB->table('Category');
$db_obj->select_options ('ORDER BY Full_Name DESC');
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
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 }
}
..then in category.html, put:
<%if cat_loop.length%>
<%loop cat_loop%>
<%include subcategory.html%>
<%endloop%>
<%endif%>
Untested, but I think this will do what you want
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
Try this global:
get_cats_from_this_cat
Code:
sub { my $cat = $_[0];
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $db_obj = $DB->table('Category');
$db_obj->select_options ('ORDER BY Full_Name DESC');
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $all_ids);
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 }
}
..then in category.html, put:
Code:
<%get_cats_from_this_cat($category_id)%> <%if cat_loop.length%>
<%loop cat_loop%>
<%include subcategory.html%>
<%endloop%>
<%endif%>
Untested, but I think this will do what you want
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
Oct 28, 2008, 9:59 AM
Veteran / Moderator (17298 posts)
Oct 28, 2008, 9:59 AM
Post #5 of 7
Views: 579
Mmm,, really? :/ Can't see any reason you would get that error (normally its due to a space at the beginning of the sub { bit or an extra space in sub { - can you send over GLinks admin details, and I'll take a look otherwise.
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
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
Oct 30, 2008, 5:43 AM
Veteran / Moderator (17298 posts)
Oct 30, 2008, 5:43 AM
Post #7 of 7
Views: 554
haha cool
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
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

