Does someone know the global that show the sub category of specific category (the same global that call category in the category page )?
Mar 2, 2008, 10:51 AM
Veteran / Moderator (18436 posts)
Mar 2, 2008, 10:51 AM
Post #2 of 9
Views: 4558
nir wrote:
Does someone know the global that show the sub category of specific category (the same global that call category in the category page )?You mean something like this?:
<%get_sub_cats($category_id)%> (will only work on category.html)
Code:
sub { my $cat_id = $_[0];
my $tbl = $DB->table( 'Category');
$tbl->select_options('ORDER BY Name');
my $sth = $tbl->select( { FatherID => $cat_id } ) || die $GT::SQL::error;
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
push @loop, $hit;
}
return { subcat_loop => \@loop };
}
Hope that helps.
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!
Mar 5, 2008, 3:02 AM
Veteran / Moderator (18436 posts)
Mar 5, 2008, 3:02 AM
Post #5 of 9
Views: 4529
Hi,
Sorry, realised I didn't give you the code to loop through =)
Try:
<%loop subcat_loop%>
<a href="<%URL%>"><%Full_Name%></a> <br />
<%endloop%>
<%endif%>
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!
Sorry, realised I didn't give you the code to loop through =)
Try:
Code:
<%if subcat_loop.length%> <%loop subcat_loop%>
<a href="<%URL%>"><%Full_Name%></a> <br />
<%endloop%>
<%endif%>
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!
Mar 5, 2008, 5:01 AM
Veteran / Moderator (18436 posts)
Mar 5, 2008, 5:01 AM
Post #7 of 9
Views: 4524
Guessing it works ok now? :)
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!
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!
Jul 29, 2008, 8:58 PM
Novice (9 posts)
Jul 29, 2008, 8:58 PM
Post #8 of 9
Views: 4476
Andy wrote:
nir wrote:
Does someone know the global that show the sub category of specific category (the same global that call category in the category page )?You mean something like this?:
<%get_sub_cats($category_id)%> (will only work on category.html)
Hi Andy,
how can I do that for the home.html? I would like to display a subcategory on the index page.
Jul 29, 2008, 11:25 PM
Veteran / Moderator (18436 posts)
Jul 29, 2008, 11:25 PM
Post #9 of 9
Views: 4449
Hi,
You would just call it with the category number hard-coded, instead of $category_id. For example
<%get_sub_cats(1234)%>
(where 1234 is the category you wanna show)
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!
You would just call it with the category number hard-coded, instead of $category_id. For example
<%get_sub_cats(1234)%>
(where 1234 is the category you wanna show)
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!