Gossamer Forum
Home : Products : Links 2.0 : Customization :

Yahoo Style Category with bold Main Category

Quote Reply
Yahoo Style Category with bold Main Category
Our site uses the yahoo style categories. We are having a problem with the main category not showing up in Bold and Larger than the Subcategories underneath. Can anyone help.
Quote Reply
Re: [rcwolfie] Yahoo Style Category with bold Main Category In reply to
The appearance of the category listing is defined in site_htm_templates, in the site_html_print_cat routine (where you added the Yahoo mod):

Code:
$output .= qq|<a class="boldnav" href="$url">$category_name</a>
<span class="smalltype">($numlinks)</span>\n|;
$output .= qq|</span>|;

if ($#{$subcategories{$subcat}} >= 0) {
$v = 0;

$output .= qq~<span class="boxtext">~;

foreach $subcatsub (sort byfield @{$subcategories{$subcat}}) {
($nonenglish) = @{$category{$subcatsub}}[8];
$subcatsub2 = $subcatsub;
$subcatsub2 = $nonenglish if ($nonenglish);
$suburl = "$build_root_url/" . &urlencode($subcatsub) . "/";
if ($subcatsub2 =~ m,.*/([^/]+)$,) { $subcategory_name = &build_last_title_mb($1); }
else { $subcategory_name = &build_last_title_mb($subcatsub2); }

$output .= qq~<A class="bodynav" HREF="$suburl">$subcategory_name</A>~

if ($v <= 5);
$output .= qq~,&nbsp; ~ if ($v ne $#{$subcategories{$subcat}} && $v <= 5);
$output .= qq~<A class="smallnav" HREF="
$url"> more</A>...~ if ($v eq "5");
$v++;
}
$output .= qq~</span></span>~;
Mine includes the nonenglish mod, and some other alterations, and everything is defined by CSS. You can insert your HTML markup here if you don't use CSS. The green is the main category, and the red is the subcats.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Yahoo Style Category with bold Main Category In reply to
I'm not sure exactly where to add these lines. This is what my sub site_html_print_cat section currently looks like:

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.
# Albert cat edit is here


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"><font face=arial size=2><table width="95%" border="0" cellspacing="5" cellpadding="5"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];
($subcatstyle) = @{$category{$subcat}}[8];



# 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|<br><a class="link" href="$url">$category_name</a> <font class="numlinks">($numlinks)</font> |;
$output .= qq|<font><sup class="new">new</sup></font>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|<dd><span class="descript">$description</span></dd>| if (!($description =~ /^[\s\n]*$/));
$output .= qq|<br>|;


if ($subcatstyle =~ m,^\(([^\)]+)\)(\d)$, && $#{$subcategories{$subcat}} >= 0) {
($subcatstyle, $style) = ($1, $2);
$s = 0;
@subcatsub = split (/\|/, $subcatstyle);
$output .= qq~ ~ if ($style eq "1");
foreach $category_name (@subcatsub) {
foreach (sort @{$subcategories{$subcat}}) {
($subcatstyle 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~, ~ and $length += 2 if ($style eq "1");
$output .= qq~ ~ if ($style eq "2");
}
$url = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~<LI>~ if ($style eq "2");
$output .= qq~<a class="subcat" href="$url">$category_name</a>~;
$s++;
last if ($subcatstyle ne "ALL" && $#subcatsub > 0);
}
}
undef $length;
if ($s < $#{$subcategories{$subcat}}) {
$output .= qq~...~ if ($style eq "1");
}
$output .= qq~<BR>~;
}
else { }}

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


1;
Now where would I insert the code?

Thanks in advance,

Richard
Everythingelpaso.com

Quote Reply
Re: [rcwolfie] Yahoo Style Category with bold Main Category In reply to
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.
# Albert cat edit is here


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"><font face=arial size=2><table width="95%" border="0" cellspacing="5" cellpadding="5"><tr><td class="catlist" valign="top">\n|;

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];
($subcatstyle) = @{$category{$subcat}}[8];



# 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|
<a class="link" href="$url">$category_name</a> <font class="numlinks">($numlinks)</font> |;
$output .= qq|<font><sup class="new">new</sup></font>| if (&days_old($mod) < $db_new_cutoff);

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


if ($subcatstyle =~ m,^\(([^\)]+)\)(\d)$, && $#{$subcategories{$subcat}} >= 0) {
($subcatstyle, $style) = ($1, $2);
$s = 0;
@subcatsub = split (/\|/, $subcatstyle);
$output .= qq~ ~ if ($style eq "1");
foreach $category_name (@subcatsub) {
foreach (sort @{$subcategories{$subcat}}) {
($subcatstyle 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~, ~ and $length += 2 if ($style eq "1");
$output .= qq~ ~ if ($style eq "2");
}
$url = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~<LI>~ if ($style eq "2");
$output .= qq~<a class="subcat" href="$url">$category_name</a>~;
$s++;
last if ($subcatstyle ne "ALL" && $#subcatsub > 0);
}
}
undef $length;
if ($s < $#{$subcategories{$subcat}}) {
$output .= qq~...~ if ($style eq "1");
}
$output .= qq~<BR>~;
}
else { }}

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


1;

It also looks like you are using style sheets etc. check your links.css (or whatever you called it) and look at your fields for margin, numlinks and subcat. It maybe that you have your font features defined in their also.

Stu2000

- Top 100 forums / GT Links 2.0 websites -
Quote Reply
Re: [rcwolfie] Yahoo Style Category with bold Main Category In reply to
Apparently we're using two VERY different mods. The code I posted would go between "#Now we print out the name linked..." and "#Don't forget to end the unordered list." What I have is there instead of what you have, not in addition to it.

As Stu2000 pointed out, the code you posted is using stylesheets. If you just copied that code into the routine, without adding the styles to your stylesheet, then the font (face, weight, color, and size) would revert to whatever is default for the page, instead of the desired one. Where did you find that particular mod?


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Yahoo Style Category with bold Main Category In reply to
I got the Yahoo Style Mod from: http://gossamer-threads.com/...ttach/1072-MyMod.txt.

As to the stylesheet, I have no idea. When this script was first created for us about 2 years ago, I did not really understand perl/CGI or stylesheets for that matter. (I should reiterate that I still don't know that much today.) Where would I find my stylesheet if there is one? And if not, how do I create one to get the look that I want?

I searched my server last night for anything using the extension *.css and I found nothing. Would it have a different extension?

Thanks,

Richard
Everythingelpaso.com
Quote Reply
Re: [rcwolfie] Yahoo Style Category with bold Main Category In reply to
Your site looks good, but I see how the category listing needs more contrast. The stylesheet was included in the download of Links, and should be on the server in the 'www' or 'html' or 'public' directory, whatever your host calls the place you put your publically accessible pages. Links came with one called links.css. However, on checking your source code, I didn't see the reference to it, which goes in the <head> </head> section, and looks like this:

Code:
<link
rel="stylesheet"
type="text/css"
href="http://yoururlhere/links.css" />


You can either find your copy of links.css, create your own, or since you're not using CSS for anything else, just put the markup in the perl code you posted before. That's probably easiest for now, but I would certainly make the effort to switch to CSS.

Just add the green part as shown here (also note some <font> tags are deleted):

Code:
$output .= qq|<b>
<a class="link" href="$url">$category_name</a></b><small>($numlinks)</small>|;
$output .= qq|<sup class="new">new</sup>| if (&days_old($mod) < $db_new_cutoff);

Then change your <font> tags to look like these (blue). Font tags do not go outside the <table>, but inside the <td>. Compare this to your original code to see changes.

Code:
# Print Header.
$output = qq|<div class="margin"><table width="95%" border="0" cellspacing="5" cellpadding="5">
<tr><td>class="catlist" valign="top"><font face=arial size=2>\n|;

...more code...

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


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Dec 4, 2002, 11:21 AM