I beleive that is what the code does.
in one of the earlier posts. that is the loop that prints the category. Specifically, it prints at
After it prints the new icons, it starts another for loop where it looks like it prints the subcategories
But I don't understand the ($numlinks) in the above. $numlinks was used to print the number of links in the category and has not been changed or reset to 0. I'm thinking it should have been $subnumlinks.
Here is my code. The only thing that seems really different is the additional for loop on the subcats.
Code:
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, $mycat, $category_name, $description, $output, $i, $subcatlinks);
my ($half) = int (($#subcat+2) / 2);
$output = qq|<TABLE BGCOLOR="blue" WIDTH="420" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR><TD WIDTH="50%" VALIGN="TOP">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5"><TR><TD VALIGN="TOP">\n|;
# Sort by Category Mod 11-20-2000. Gene.
# Comment out the following line and add the two lines after and before ($desc...
#foreach $subcat (sort @subcat) {
sub byfield { $category{$a}[$cat_sort_field] cmp $category{$b}[$cat_sort_field] };
# new images mod Mod 11-20-2000. Gene.
# foreach $subcat (sort byfield @subcat) {
# ($description) = @{$category{$subcat}}[2];
foreach $subcat (sort byfield @subcat) {
my $mod = $stats{"$subcat"}[3];
my $new_add = $stats{"$subcat"}[4];
($description) = @{$category{$subcat}}[2];
#new images Mod 11-20-2000. Gene.
# yahoo Mod 11-20-2000. Gene.
($subcatstyle) = @{$category{$subcat}}[9];
# 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];
$subcatlinks = $substats{"$subcat"};
# new images Mod 11-20-2000. Gene.
# $mod = $stats{"$subcat"}[1];
# 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 == $half) {
$output .= qq|</TD></TR></TABLE></TD><TD WIDTH="50%" VALIGN="TOP">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="5">
<TR><TD VALIGN="TOP">\n|;
}
$i++;
# yahoo Mod 11-20-2000. Gene.
# Then we print out the name linked, new if it's new, and popular if its popular.
# my mod to carry forward the cat name
$mycat = $category_name;
$output .= qq|<a class="menulink2" class=&{ns4class} href="$url"
onmouseover="window.status=' Check out the Listings in $category_name'; return true"
onmouseout="window.status=' '">$category_name|;
# mod to not print 0 links 1-14-2001. Gene.
if ($numlinks > 0) {
$output .= qq| ($numlinks)|;
}
$output .= qq|</a>|;
#new images Mod 11-20-2000. Gene.
# $output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
# if ($new_add eq "Yes") {
# $days_old = &days_old($stats{"$subcat"}[2]);
# if ($days_old <= 9) { $output .= qq| $new_1|; }
# elsif ($days_old <= 19) { $output .= qq| $new_3|; }
# elsif ($days_old <= 30) { $output .= qq| $new_7|; }
# }
# if ($mod eq "Yes") { $output .= qq~ $updated~;}
#new images Mod 11-20-2000. Gene.
# $output .= qq|<BR>|;
# mod for no links in cat end
if ($subcatstyle =~ m,^\(([^\)]+)\)(\d)$, && $#{$subcategories{$subcat}} >= 0) {
($subcatstyle, $style) = ($1, $2);
$s = 0;
@subcatsub = split (/\|/, $subcatstyle);
$output .= qq~~ if ($style eq "1");
foreach $category_name (@subcatsub) { foreach (sort @{$subcategories{$subcat}}) {
($subcatstyle eq "ALL" && $#subcatsub == 0) ?
($_ =~ m,.*/([^/]+)$, and $category_name = &build_clean($1)) :
($_ eq "$subcat/$category_name" or next);
if ($style eq "1") {
$length += length($category_name);
($length > $subcat_length) and last;
}
#calc number of links in subcats $subcatlinks = $substats{$_};
if ($s > 0) {
$output .= qq~~ and $length += 2 if ($style eq "1");
$output .= qq~~ if ($style eq "2");
}
$url = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~ ~ if ($style eq "2");
$output .= qq~<a class="menulink2" class=&{ns4class} href="$url"
onmouseover="window.status=' Check out the Listings in $category_name, $mycat'; return true;"
onmouseout="window.status=' '; return true;"> $category_name~;
if ($subcatlinks){
$output .= qq~
($subcatlinks)~;
}
$output .= qq~</a>~;
$s++;
last if ($subcatstyle ne "ALL" && $#subcatsub > 0);
}
} undef $length;
if ($s < $#{$subcategories{$subcat}}) {
$output .= qq~...~ if ($style eq "1");
}
$output .= qq~~;
$output .= qq||;
}
else { }
}
# Don't forget to end the unordered list..
# $output .= "</td></tr></table>\n";
$output .= "</TD></TR></TABLE><BR></TD></TR></TABLE>\n";
return $output;
}
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."