Gossamer Forum
Home : Products : Links 2.0 : Customization :

Yahoo Subcats

Quote Reply
Yahoo Subcats
Hey everyone,

I just can't seem to get the Yahoo Categories mod to work for me. I had already installed the nonenglish mod and priority links mods successfully, and after making all the correct modifications to my files for the Yahoo mod...it just won't do anything to my categories. It hasn't changed the look at all. I don't get any error messages at all, so I don't exactly know where I went wrong.

Anybody else have this problem? Is there something I need to put on my templates? Please explain. The templates I use are the ones that came with the Links 2 files. I modify the home.html file and categories.html etc etc.

Thanks for your help!
Quote Reply
Re: [SHANX6336] Yahoo Subcats In reply to
OK, the code below is far from original, but mixed in it are the parts you need to make nonenglish/yahoo work for you. Ignore most of the output=stuff, as it is designed to my site. I have made the parts I think you need to change red, but you'll have to experiment some...
Also, this is set to have the nonenglish as field 8 in cat.def. And, I have removed a few bits from what I have on my site, so if it looks like something's missing that should be there, probably it should be.


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) = @_;
# ***************************************** nonenglish modification - begin ****************
# my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i, $nonenglish, $columns, $subcatsub);
# ***************************************** nonenglish modification - end ******************
##added next line LT nonenglish/yahoo mod
# my ($half) = int (($#subcat+2) / 2);
$columns = '2'; #number of columns
my ($half) = int (($#subcat+2) / $columns);


$output = qq|<table width="562" border="0" cellspacing="0" cellpadding="0">\n|;
$output .= qq|<tr><td width="50%" valign="top">\n|;
# $output .= qq|<table width="275" border="0" cellspacing="0" cellpadding="0">\n|;

##***next two lines changed LT for arbitraty order mod***
sub byfield { $category{$a}[$cat_sort_field] <=> $category{$b}[$cat_sort_field] };
foreach $subcat (sort byfield @subcat) {
($description) = @{$category{$subcat}}[2];
# ***************************************** nonenglish modification - begin ****************
($nonenglish) = @{$category{$subcat}}[8];
$subcatsub = $nonenglish if ($nonenglish);


# ***************************************** nonenglish modification - end ******************

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
# ***************************************** nonenglish modification - begin ****************
# if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
if ($nonenglish eq "") {
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
}
else {
$category_name = &build_last_title_mb($nonenglish);
}
# ***************************************** nonenglish modification - end ******************


$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];
if ($i == $half) {
$output .= qq~</td><td width="50%" valign="top">\n~;
# $output .= qq~</table></td><td width="275" valign="top"><table width="275" border="0" cellspacing="0" cellpadding="0">\n~;
$i = 0;
}

# Then we print out the name linked, new if it's new, and popular if its popular.

# $output .= qq|<tr><td>\n|;
$output .= qq|<span class="home6e">\n|;
$output .= qq|<span class="home6d">\n|;

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

$output .= qq|</span>|;

### next added LT 2002-Yahoo###
### added 'byfield' for arbitrary order mod###
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>~;
# $output .= qq~</td></tr>~;
}
###end added LT###
#LT $output .= qq|<dd><span class="descript">$description
#</span></dd>| if (!($description =~ /^[\s\n]*$/));
# $output .= qq|</dl></font></td>\n|;
$i++;
}
$output .= "</td></tr></table>\n";
return $output;
}


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Feb 5, 2003, 11:04 PM
Quote Reply
Re: [SHANX6336] Yahoo Subcats In reply to
Thanks for your reply. When I made the changes you suggested, I got the following error message when I was trying to build..Error including libraries: Missing right curly or square bracket at /home/shant5/iglendale-www/cgi-bin/db/admin/site_html_templates.pl line 525, at end of linesyntax error at /home/shant5/iglendale-www/cgi-bin/db/admin/site_html_templates.pl line 525, at EOFCompilation failed in require at nph-build.cgi line 33.Make sure they exist, permissions are set properly, and paths are set correctly.



To view my site_html_templates.pl file, go to

http://www.iglendale.com/site_html_templates.txt



Thanks for your help, let me know if you can find my problem.
Quote Reply
Re: [SHANX6336] Yahoo Subcats In reply to
Your're using two different yahoo mods, the one you added before, which includes this code:

Code:
if ($subcatstyle =~ m,^\(([^\)]+)\)(\d)$, && $#{$subcategories{$subcat}} >= 0) {
($subcatstyle, $style) = ($1, $2);
$s = 0;
@subcatsub = split (/\|/, $subcatstyle);
$output .= qq~&nbsp;&nbsp;&nbsp;&nbsp;~ 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");


and the one I posted. I suggest deleting the first one. try just using the code I posted before, and change the outputs to match what you want. Gotta run right now, will check in later...


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Yahoo Subcats In reply to
Thank you for your assistance...I changed the information and just used the file you gave me in the first reply over anything I already had. When I tried to build my DB, I got the following error...

CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine &main::build_last_title_mb called at /home/shant5/iglendale-www/cgi-bin/db/admin/site_html_templates.pl line 422.

Script Location : nph-build.cgi
Perl Version : 5.006001


Please tell me what I should do next.

Thanks for your help!
Quote Reply
Re: [SHANX6336] Yahoo Subcats In reply to
 
The error tells you what sub is missing, so add it to the bottom of site_html_templates.pl, just before the 1; Just to be safe, add all the subs below. (You should already have one of them, just past this code over it.)



# ***************************************** nonenglish modification - begin ****************
sub build_clean_mb {
# --------------------------------------------------------
my ($input) = $_[0];
$input =~ s,\\, : ,g;
return $input;
}

sub build_last_title_mb {
# --------------------------------------------------------
my ($input) = $_[0];
my (@descs, $output);

@descs = split (/\\/, $input);
$output = pop (@descs);

return $output;
}

sub build_linked_title_mb {
# --------------------------------------------------------
# Returns a string of the current category broken up
# by section, with each part linked to the respective section.

my ($input) = $_[0];
my ($description) = $_[1];
my (@dirs, $dir, $output, $path, $last, @descs, $desc);

@dirs = split (/\//, $input);
@descs = split (/\\/, $description);
$last = pop (@dirs);
$last = pop (@descs);

$output = qq| <A HREF="$build_root_url/">Top</A> :|;
foreach $dir (@dirs) {
$path .= "/$dir";
$desc = shift (@descs);
$output .= qq| <A HREF="$build_root_url$path/">$desc</A> :|;
}
$output .= " $last";

return $output;
}

sub kategorie_title_mb {
# --------------------------------------------------------
my ($input, $output, $title, $kategorie, @fields);

$input = $_[0];
$title = "";

KATEGORIE: foreach $kategorie (@kategorien) {
if ($kategorie =~ /^#/) { next KATEGORIE; } # Skip comment lines.
chomp ($kategorie);
@fields = &split_decode ($kategorie);
if ($fields[1] eq $input) {
$title = $fields[8];
last KATEGORIE;
}
}
if ($title eq "") {
$output = &build_clean ($input);
}
else {
$output = &build_clean_mb ($title);
}

return $output;
}
# ***************************************** nonenglish modification - end ******************


Leonard
aka PerlFlunkie
Quote Reply
Re: [SHANX6336] Yahoo Subcats In reply to
Thank you so much!!! It finally started working. If you need any internet services like web hosting or promotion, I can really get you big discounts with a great site solutions company. Let me know. I seriously owe you a lot, thanks!