Gossamer Forum
Home : Products : Links 2.0 : Customization :

what's wrong with this code?!?

Quote Reply
what's wrong with this code?!?
I've posted this inquiry a couple of times already - I apologize for taking up extra space - but I'm really baffled. Can anyone out there tell me what the heck is wrong with this code that it prints all of my categories in only one column? It's straight from the script resources template and incorporates RedRum's subcategories mod. I will be so eternally grateful if someone can help me figure this out:



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);



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];



# Then we print out the name linked, new if it's new, and popular if its popular.

$output .= qq|<tr><td><font face="Verdana, Helevtica, Arial" size=2><dl><dt><strong><a href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;

$output .= qq|<small><font color="red">new</font></small>| if (&days_old($mod) < $db_new_cutoff);

$output .= qq|</dt>|;

$output .= qq|<br><small>| . qq|&nbsp;| x 4;

$j=0;

for (@{$subcategories{$subcat}}) {

if (m,^\Q$subcat\E/([^/]+)$,) {

$child = ($1);

if ($hyperlink) {

$output .= qq|<a href="$build_root_url/$subcat/$child/">$child</a>,|

}

else {

$output .= qq|$child,|

}

$j++;

if ($j == $max_subs) {

last;

$j = 0;

}

}

}

chop $output;

$output .= qq|</small><br>|;

$output .= qq|<dd><span class="descript">$description </span></dd>| if (!($description =~ /^[\s\n]*$/));

$output .= qq|</dl></font></td></tr>|;

}

return $output;

}

1;



Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [davidziel] what's wrong with this code?!? In reply to
Looks like your missing the bit splitting the table in half.

# 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++;

Last edited by:

RedRum: Jan 3, 2002, 2:19 PM
Quote Reply
Re: [RedRum] what's wrong with this code?!? In reply to
Well I feel pretty stupid about that. However, I put it in where I assume it should go and I'm still experiencing the same problem. Here's the current code for that first section:

Code:


my (@subcat) = @_;

my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);

my ($half) = int (($#subcat+2) / 2);

$output = qq|<tr><td width="50%">|;



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 width="50%" valign="top">\n|;

}

$i++;



Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [davidziel] what's wrong with this code?!? In reply to
Could it be that it's not properly retrieving the number of subcategories, perhaps?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [davidziel] what's wrong with this code?!? In reply to
Well, if anyone's interested, I finally figured this problem out. For some reason, I was missing the:

Code:


$output .= "</td></tr></table></div>\n";

at the very end. I put that back in, and now it's working. Sorry to have taken up so much space on the forum with this stupid problem and thanks to those who attempted to help.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund