Hi,
Im looking into a way of setting up Links SQL to display categories on the home page depending on a custom value in the category table and breaking each category link into different columns based on the total number, eg.
Browse by Brand
Cat link 1 - Cat link 6
Cat link 2 - Cat link 7
Cat link 3 - etc.
Cat link 4
Cat link 5
Here's an copy of the sub im using (based on one of Laura's from the UK high street site):
Code:
sub { # -------------------------------------------------------------------
my $tags = shift;
my $cat_db = $DB->table('Category');
$cat_db->select_options ('ORDER BY Full_Name');
my $sth = $cat_db->select ( { FatherID => 0, CategoryType => 'Brand'}, ['Full_Name','ID','Name'] );
my $output=qq~~;
my $i=0;
while (my ($root_cat,$ID,$heading) = $sth->fetchrow_array) {
$i++;
my $url1 = $cat_db->as_url($root_cat);
$output.= qq~<a href="$CFG->{build_root_url}/$url1/" class="internal">$heading</a><br />\n~;
$cat_db->select_options ('ORDER BY Full_Name');
}
return $output;
}
Currently this sub outputs all the links in one column:
Cat link 1
Cat link 2
Cat link 3
Cat link 4
Cat link 5
Cat link 6
Cat link 7
etc.
Can anyone suggest a way to calculate the total number of categories due to be displayed and divide them by 2 or 3 to split them into 2 or 3 columns evenly?
thanks in advance for your help,
Charlie
Comedy Quotes - Glinks 3.3.0, PageBuilder, StaticURLtr, CAPTCHA, User_Edit_Profile