A Mod to the Yahoo Style SubCategory Listings Mod by Widgetz.
I wanted to use the Yahoo style Sub-Category listings on my site, but I also wanted to keep the
ability to use the category descriptions. So I came up with this mod to Widgetz Mod to allow
just that.
Notes:
1. Remember to backup files to be edited before proceeding.
2.This Mod assumes no previous mods are installed and you are using templates.
3.If you have an existing categories.db file, you should review information
on Bobsie's upgrade script at
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/001090.html .
This will help you add the new field spacing to your categories.db.
links/cgi-bin/admin/category.def
Find this section: (it's at the top)
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
);
Palace this line under the last entry in the list just before the );
^ ^
Filed ID Default Entry
The field id, in this case 8 should be changed to reflect the fields sequence in your database.
Don't forget to place a comma at the end of the entry on the line above SubCatStyle. You can indicate
a default style by placing one of the styles from the bottom of this post in the Default Entry section
of the field definition.
links/cgi-bin/admin/site_html_templates.pl
Find this:
($description) = @{$category{$subcat}}[2];
Place this just below it
Change the filed ID to match the one you entered in the category.def
Find this comment line:
Replace with:
$output .= qq|<a class="catlist" href="$url">$category_name</a> <font class="catlist">($numlinks)</font> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$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 table..
$output .= "</td></tr></table></div>\n";
return $output;
}
If you wish the catagory despcription to be displayed rather than the catagory name replace
with
links/cgi-bin/admin/links.cfg
Find this section (it's close to the bottom)
# the directory though!
$build_site_title = 'Gossamer Threads';
Insert this bellow it
$subcat_length = '30';
That's it for the CGI Work. Now you need to add the place holder for the new field to your
category database (links/cgi-bin/admin/data/categories.db).
To do this just add a | (see note 3 above) to the end of each record in your database.
To use this mod indicate what style of subcategory listing you would like by entering one of the
styles below in the SubCatStyle filed in the Modify Category screen of the Links Admin page.
Horizontal Layout (alphabetical.. up to subcat_length)
(ALL)1
Category (#)
Subcategory1, Subcategory2, Subcategory3...
Vertical Layout (alphabetical)
(ALL)2
Category (#)
* Subcategory1
* Subcategory2
* Subcategory3
* Subcategory4
Horizontal Layout (ordered by you)
(Games|Utilities|Hacks)1
Category (#)
Games, Utilities, Hacks
Vertical Layout (ordered by you)
(Games|Utilites|Hacks)2
Category (#)
* Games
* Utilities
* Hacks
That should do it. If you have problems I will do my best to help you. Just post them to this
thread and I will respond as quickly as possible.
----------------------
Bert Gaddis
SysOp, The-BBS.COM
www.the-bbs.com
----------------------
[This message has been edited by Kraken (edited February 29, 2000).]
I wanted to use the Yahoo style Sub-Category listings on my site, but I also wanted to keep the
ability to use the category descriptions. So I came up with this mod to Widgetz Mod to allow
just that.
Notes:
1. Remember to backup files to be edited before proceeding.
2.This Mod assumes no previous mods are installed and you are using templates.
3.If you have an existing categories.db file, you should review information
on Bobsie's upgrade script at
www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/001090.html .
This will help you add the new field spacing to your categories.db.
links/cgi-bin/admin/category.def
Find this section: (it's at the top)
Code:
# Definition of your database file. %db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 500, 0, '', ''],
Related => [3, 'alpha', 0, 255, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 75, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 75, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
);
Palace this line under the last entry in the list just before the );
Code:
SubCatStyle => [8, 'alpha' ,40, 100, 0, '(ALL)1', ''] ^ ^
Filed ID Default Entry
The field id, in this case 8 should be changed to reflect the fields sequence in your database.
Don't forget to place a comma at the end of the entry on the line above SubCatStyle. You can indicate
a default style by placing one of the styles from the bottom of this post in the Default Entry section
of the field definition.
links/cgi-bin/admin/site_html_templates.pl
Find this:
Code:
foreach $subcat (sort @subcat) { ($description) = @{$category{$subcat}}[2];
Place this just below it
Code:
($subcatstyle) = @{$category{$subcat}}[8];Change the filed ID to match the one you entered in the category.def
Find this comment line:
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.Replace with:
Code:
# Then we print out the name linked, new if it's new, and popular if its popular. $output .= qq|<a class="catlist" href="$url">$category_name</a> <font class="catlist">($numlinks)</font> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$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 table..
$output .= "</td></tr></table></div>\n";
return $output;
}
If you wish the catagory despcription to be displayed rather than the catagory name replace
Code:
$output .= qq|<a class="catlist" href="$url">$category_name</a> <font class="catlist">($numlinks)</font> |;with
Code:
$output .= qq|<a class="catlist" href="$url">$description</a> <font class="catlist">($numlinks)</font> |;links/cgi-bin/admin/links.cfg
Find this section (it's close to the bottom)
Code:
# Site Title, the default title to use. You should really spend some time customizing # the directory though!
$build_site_title = 'Gossamer Threads';
Insert this bellow it
Code:
# Subcategory Length, the maximum length of the subcategories added into Links. $subcat_length = '30';
That's it for the CGI Work. Now you need to add the place holder for the new field to your
category database (links/cgi-bin/admin/data/categories.db).
To do this just add a | (see note 3 above) to the end of each record in your database.
To use this mod indicate what style of subcategory listing you would like by entering one of the
styles below in the SubCatStyle filed in the Modify Category screen of the Links Admin page.
Code:
Style Types... Horizontal Layout (alphabetical.. up to subcat_length)
(ALL)1
Category (#)
Subcategory1, Subcategory2, Subcategory3...
Vertical Layout (alphabetical)
(ALL)2
Category (#)
* Subcategory1
* Subcategory2
* Subcategory3
* Subcategory4
Horizontal Layout (ordered by you)
(Games|Utilities|Hacks)1
Category (#)
Games, Utilities, Hacks
Vertical Layout (ordered by you)
(Games|Utilites|Hacks)2
Category (#)
* Games
* Utilities
* Hacks
That should do it. If you have problems I will do my best to help you. Just post them to this
thread and I will respond as quickly as possible.
----------------------
Bert Gaddis
SysOp, The-BBS.COM
www.the-bbs.com
----------------------
[This message has been edited by Kraken (edited February 29, 2000).]