Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Links counter not working on some sub-categories

Quote Reply
Links counter not working on some sub-categories
Hi all,

My Links database is for some reason not putting a number (from $numlinks) for the number of links on some intermediary sub-categories.

Here, in symbolic form, is what I get when I build the HTML pages:
Code:
Category Name...........(number of links)

Top Level Category 1 .........(31)
Sub-Category 1 ...........(0)
Sub-sub-category 1..(31)

Only the topmost and bottommost category descriptions on the html pages show how many links are contained within. The interceding categories that do not contain any actual links just print the (0).

Maybe I'm looking too hard but I can't for the life of me figure this one out.

Here's my code from site_html_templates.pl (notice I commented-out the part that builds the categories into a two column layout):
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, $category_name, $description, $output, $i);
my ($half) = int (($#subcat+2) / 2);

# Print Header.
$output = qq|<div class="margin"><table width="80%" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];

# 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];
$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><td class="catlist" valign="top">\n|;
# }
# $i++;

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl>|;
}

# Don't forget to end the unordered list..
$output .= "</td></tr></table></div>\n";
return $output;
}

1;

This problem wouldn't be because I commented-out the $i++; line would it?

So you know, I have the following mods installed:
1. Bulkload - for bulk uploading of records,
2. Restricted Categories - disallows the addition of links to certain categories (definitely a suspect),
3. A Security Mod.

Douglas

Quote Reply
Re: Links counter not working on some sub-categories In reply to
Yes...you need to have the i++ active so that number of links number can increment.

Regards.

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Links counter not working on some sub-categories In reply to
Eliot,

WOO HOO! Thanks!

I had tried so many things to fix it that by the time I saw that $i++; thing I had run out of steam.

Thank you again for your confirmation.

'Tis Friday night and I am NOW going to have that drink Smile

Douglas