Gossamer Forum
Home : Products : Links 2.0 : Customization :

category heading background color

Quote Reply
category heading background color
I want to have a background color for Category heading and white background for the description of that category.
This is my code I tried many things and I cant get it right. Right now I have background for the cell in the table. both header and description appear in the same cell so both have same background.
take a look at cgi-resources main page this is how I want the background color for my categories
http://www.cgi-resources.com/

$output .= qq|<td width="50%" valign="top" ><dl><dt><strong><font face="Verdana, Arial, Helvetica" size="2"><a class="link" href="$url">$category_name</a></strong></font> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">new</sup></small></td>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</dt>|;
$output .= qq|<dd> <span class="descript"><font face="Verdana, Arial, Helvetica" size="1">$description </font></span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</dl></td>|;

Quote Reply
Re: category heading background color In reply to
You just need to build a nested table. Place the appropriate HTML tags in the $output variable. The following codes emulate their category format:
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<table>|;
$output .= qq|<tr><td bgcolor="#cccccc" colspan="2">|;
$output .= qq|<a class="link" href="$url">$category_name</a> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|</td></tr>|;
$output .= qq|<tr><td bgcolor="#ffffff" width="15"> </td><td bgcolor="#eeeeee">|;
$output .= qq|<span class="descript">$description </span>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|</td></tr>|;
$output .= qq|</table><.br>|;
Remove the . in <.br> (this forum keeps interpretting the BR tag, even with named character entities...)

--Drew
Quote Reply
Re: category heading background color In reply to
thanks for the help but it didnt work! May be I should have displayed more of the code. I have 2 column of categories. here is my code again. I have been playing around with this for 2 days with no success.






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="98%" border="0" cellspacing="5" cellpadding="5" bgcolor="docc98">\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 == 2) {
$output .= qq|</tr><tr>\n|;
$i = 0;
}
$i++;

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

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

1;

Quote Reply
Re: category heading background color In reply to
Your coding is all messed up. Place the codes I gave you in a fresh site_html_print_cat, or start by fixing the following codes:

missing <tr> at the end of:
Code:
$output = qq|<div class="margin"><table width="98%" border="0" cellspacing="5" cellpadding="5" bgcolor="docc98">\n|;
should look like:
Code:
$output = qq|<div class="margin"><table width="98%" border="0" cellspacing="5" cellpadding="5" bgcolor="docc98"><tr>\n|;
Closing a row (without starting one), then starting a new row, and in the wrong place anyway:
Code:
$output .= qq|</tr><tr>\n|;
should look like:
Code:
$output .= qq|</td><td class="catlist" valign="top">\n|;
And there are still more... Can you find them?

--Drew