Is it possible to modify sub site_html_print_cat so that the links are output into 3 columns instead of 2?
May 7, 2004, 9:53 PM
Novice (46 posts)
May 7, 2004, 9:53 PM
Post #4 of 5
Views: 3724
I searched the forum and found a solution. I modified it a little bit and now this is what my sub site_html_print_cat code looks like in site_html_templates.html file. It is 3 columns with bullet points next to each sub-category link. Hope this helps someone else!!
sub site_html_print_cat {
# --------------------------------------------------------
# This routine determines how the list of categories will look.
# We now use a table to split the category name up into two columns.
# For each category you can use the following variables:
#
# $url : The URL to go to that category
# $category_name : The category name with _ and / removed.
# $category_descriptions{$subcat}: The category description (if any).
# $numlinks : The number of links inside that category (and subcategories).
# $mod : The newest link inside of that category.
#
my (@subcat) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($third) = int ((($#subcat+2) / 3)+1);
# Print Header.
$output = qq|<table width="85%" align="center" border="0" cellspacing="0" cellpadding="0"><tr><td width="33%" class="catlist" valign="top"><ul>\n|;
foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];
my $mod = $stats{"$subcat"}[3];
my $new_add = $stats{"$subcat"}[4];
# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
# We check to see if we are half way through, if so we stop this table cell
# and begin a new one (this lets us have category names in two columns).
if ($i == $third) {
$output .= qq|</ul></td><td width="33%" class="catlist" valign="top"><ul>\n|;
$i = 0;
}
$i++;
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<li><a class="link" href="$url">$category_name</a></li><br>|;
}
# Don't forget to end the unordered list..
$output .= "</td></tr></table>\n";
return $output;
}
sub site_html_print_cat {
# --------------------------------------------------------
# This routine determines how the list of categories will look.
# We now use a table to split the category name up into two columns.
# For each category you can use the following variables:
#
# $url : The URL to go to that category
# $category_name : The category name with _ and / removed.
# $category_descriptions{$subcat}: The category description (if any).
# $numlinks : The number of links inside that category (and subcategories).
# $mod : The newest link inside of that category.
#
my (@subcat) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($third) = int ((($#subcat+2) / 3)+1);
# Print Header.
$output = qq|<table width="85%" align="center" border="0" cellspacing="0" cellpadding="0"><tr><td width="33%" class="catlist" valign="top"><ul>\n|;
foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];
my $mod = $stats{"$subcat"}[3];
my $new_add = $stats{"$subcat"}[4];
# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
# We check to see if we are half way through, if so we stop this table cell
# and begin a new one (this lets us have category names in two columns).
if ($i == $third) {
$output .= qq|</ul></td><td width="33%" class="catlist" valign="top"><ul>\n|;
$i = 0;
}
$i++;
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<li><a class="link" href="$url">$category_name</a></li><br>|;
}
# Don't forget to end the unordered list..
$output .= "</td></tr></table>\n";
return $output;
}