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%>:

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

# 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
Quote Reply
Re: Two versions of Category In reply to
There is already a modification for doing this in the Resources section of this site.


Eliot Lee
Quote Reply
Re: Two versions of Category In reply to
Hm. Not exactly the most helpful answer --

I've been going through all the items in the Resources and Cool areas before I placed my post and haven't come up with anything suitable. The closest that I've found is the Subcategories like Yahoo 2.1, but that claims to be a Mod of a Mod and it certainly doesn't do what I'm asking for.

(well, that's not exactly true -- it does treat the Home Page categories differently, but it's doing stuff I don't understand as of yet.)

To reiterate, I want to have the Homepage Categories with normal descriptions. On Category pages, I want the subcategories listed by name and have no descriptions.

Perhaps a slight clue as to what has to be modified and how? Or perhaps someone out there might be able to point me to the correct mod?

Andrew "Hobeaux" Penick
Quote Reply
Re: Two versions of Category In reply to
Well, I've gone and incorporated the Yahoo subcategories and it works as the author intended (categories specified with the (all)x are treated differently)-- now i just need to change it to make it how -i- want it :)

I'll post my request in the Subcategories Like Yahoo 2.1 forum topic (http://gossamer-threads.com/...pl?ubb=004954:Forum3)

Andrew "Hobeaux" Penick