Try this mod MOD: (Mine)
SUBCATEGORIES LIKE YAHOO v2.1(Modified)
A Mod to the Yahoo Style SubCategory Listings Mod by Widgetz.
THIS MOD MUST BE USED ONLY IN site_html.pl (NO TEMPLATES).
Modified for no templates by
Eduin Yesid Carrillo yecarrillo@hotmail.com (aug 9 /2000)
I wanted to use the Yahoo style Sub-Category listings on my site, but I also wanted to
keep the ability to us category descriptions. So I came up with this mod to Widgetz
Mod to allow just that.
Notes: Remember to backup files to be edited before proceeding. This Mod assumes
no previous mods are installed and you are using templates.
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 the information
in Bobsie's upgrade script at
http://www.gossamer-threads.com/...um3/HTML/001090.html With some work it 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)
# Definition of your database file.
Code:
%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.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 sub
Code:
sub site_html_category {
Insert this below the
my ($output); entry
Code:
$subcatstyle = $category{$category_name}[8];
Change the filed ID to match the one you entered in the category.def
Find this text:
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq~<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> ~;
$output .= qq~<small><sup class="new">new</sup></small>~ if (&days_old($mod) < $db_new_cutoff);
$output .= qq~</dt>~;
$output .= qq~<dd><span class="descript">$description </span></dd>~ if (!($description =~ /^[\s\n]*$/));
$output .= qq~</dl>~;
Replace with:
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq~<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> ~;
$output .= qq~<small><sup class="new">new</sup></small>~ if (&days_old($mod) < $db_new_cutoff);
$output .= qq~</dt>~;
$output .= qq~<dd><span class="descript">$description </span></dd>~ if (!($description =~ /^[\s\n]*$/));
$output .= qq~</dl>~;
$maxitems = 3;
if ($subcatstyle =~ m,^\(([^\)]+)\)(\d)$, && $#{$subcategories{$subcat}} >= 0) {
($subcatstyle, $estilo) = ($1, $2);
$s = 0;
@subcatsub = split (/\|/, $subcatstyle);
$output .= qq~ <small>~;
$output .= qq~
~ if ($estilo 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 ($estilo eq "3") {
$length += length($category_name);
($length > $subcat_length) and last;
}
if ($s > 0) {
$output .= qq~, ~ and $length += 2 if ($estilo eq "1");
$output .= qq~ ~ if ($estilo eq "2");
}
$url = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~<LI>~ if ($estilo eq "2");
$category_name =~ s/_/ /g;
$output .= qq~<a class="subcat" href="$url">$category_name</a>~;
$s++;
# last if ($subcatstyle ne "ALL" && $#subcatsub > 0);
last if (($subcatstyle ne "ALL" && $#subcatsub > 0)||($s>$maxitems - 1));
}
}
undef $length;
# if ($s < $#{$subcategories{$subcat}}) {
if ($s >= $maxitems) {
$output .= qq~ ...~ if ($estilo eq "1");
$output .= qq~<li> ...~ if ($estilo eq "2");
}
$output .= qq~</small><BR>~;
}
else {
}
Change the $maxitems value to match the number of subcats
that you want to show for each category.
That's it for the CGI Work. No 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 email me to yecarrillo@hotmail.com
and post to the original mod
thread at
http://www.gossamer-threads.com/...um3/HTML/004954.html and I will respond as quickly as possible.