Gossamer Forum
Home : Products : Links 2.0 : Customization :

Two versions of Category

Quote Reply
Two versions of Category
Okay, the way I'm attempting to set up the Category listings on my Links site is that I want the Home Page's category listings to have the description but on sub pages I only wish to have the category names.

If I create a new subroutine, how do I get it called and assigned to a new tag? Gee, can you tell I'm new at this?

what I want is the new subroutine to be called and assigned to a new tag (such as <%category_nodesc%>:

Code:
sub site_html_category_no_desc {
# --------------------------------------------------------
# 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="400" border="0" cellspacing="0" cellpadding="0"><tr><td class="catlist" valign="top" width="195">\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 width="10"><img src="/cgi-bin/links/gui/spacer.gif" width="10"></td><td class="catlist" valign="top" width="195">\n|;
}
$i++;

# Then we print out the name linked, new if it's new.
$output .= qq|<a class="link" href="$url">$category_name</a> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<span class="new"> (new)</span>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|
|;
}

# Don't forget to end the table
$output .= "</td></tr></table></div>\n";
return $output;
}
Andrew "Hobeaux" Penick
http://www.unrealengine.com
Subject Author Views Date
Thread Two versions of Category Hobeaux 1495 Jan 3, 2001, 4:28 PM
Thread Re: Two versions of Category
Stealth 1448 Jan 3, 2001, 7:32 PM
Thread Re: Two versions of Category
Hobeaux 1441 Jan 3, 2001, 8:33 PM
Post Re: Two versions of Category
Hobeaux 1434 Jan 3, 2001, 10:12 PM