Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Help: Category pages different than category listing

Quote Reply
Help: Category pages different than category listing
I'd appreciate any help anyone can give me. I'm trying to make my category pages list subcategories single spaced while leaving the main category listing as is, i.e. recreate what is done here: http://vlib.anthrotech.com/

I've gone through every post and still am having problems. Check out my site_html_template.pl code.

(By the way, I'm using the yahoo subcategories mod v2.0 and I've altered my nph-build.cgi per http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/004980.html.)

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="100%" border="0" cellspacing="5" 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><a class="link" href="$url">$category_name</a> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<font color="#FF0000"><small><sup class="new">new</sup></small></font>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|<BR></dt>|;
if ($description =~ m,^\(([^\)]+)\)(\d)$, && $#{$subcategories{$subcat}} >= 0) {
($description, $style) = ($1, $2);
$s = 0;
@subcatsub = split (/\|/, $description);
foreach $category_name (@subcatsub) {
foreach (sort @{$subcategories{$subcat}}) {
($description eq "ALL" && $#subcatsub == 0) ?
($_ =~ m,.*/([^/]+)$, and $category_name = &build_clean($1)) :
($_ eq "$subcat/$category_name" or next);
if ($style eq "1") {
$length += length($category_name);
($length > $subcat_length) and last;
}
if ($s > 0) {
$output .= qq~<font size="1">, </font>~ and $length += 2 if ($style eq "1");
$output .= qq~<font size="1"></font><BR>~ if ($style eq "2");
}
$url = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~<font size="1"> </font>~ if ($style eq "2");
$output .= qq~<font size="1"><A href="$url">$category_name</A></font>~;
$s++;
last if ($description ne "ALL" && $#subcatsub > 0);
}
}
undef $length;
if ($s < $#{$subcategories{$subcat}}) {
$output .= qq~<font size="1">...</font>~ if ($style eq "1");
}
}

$output .= qq|</dl>|;
}

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

1;


sub site_html_print_subcat {
# --------------------------------------------------------
# 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|<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td 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 valign="top">\n|;
}
$i++;

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

}

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

1;

Quote Reply
Re: Help: Category pages different than category listing In reply to
As I have suggested to you before and other LINKS users...do the following...

---- This is a recording ----

1) Delete all the CSS codes (like <span "descript">, <sup "new"> ).

2) Delete all the definition listing codes (like <dl><dt> ).

3) Put a <br> after the $new variable.

4) Put a <br> after the $description variable.

---- End Recording ----

Please post questions like this in the LINKS MODIFICATION FORUM. That forum is for code hacking. This forum is for general discussions about LINKS.


Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Help: Category pages different than category listing In reply to
Sorry for putting this on the wrong board, feel free to move it if you want.

Thanks for your response, I thought I had done most of the stuff you mentioned but obviously not.

One more question, how come when I insert <BR> near the end of sub site_html_print_cat it effects the subcategory listings on the individual category pages? I though it was obvious that what was under the cat section altered the top page and the subcat stuff altered the category pages. I'm still having trouble making the changes I want cause I can't change cat without affecting the other.

Thanks for your help, and patience.
Quote Reply
Re: Help: Category pages different than category listing In reply to
 
Quote:
how come when I insert <BR> near the end of sub site_html_print_cat it effects the subcategory listings on the individual category pages?

Because you have not completed the Mod by editing the nph-build.cgi script.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.