Hi..
Recently, I've been working with an SQL version of my copy of Links2 and I have decided to just switch over.. So I am going to start releasing some mods that I never intended to release..
Starting with Subcategories Like Yahoo v2..
I made this quite awhile ago.. when a template user emailed me with an error.. he had thought it was usable like this:
SUB1, SUB2, SUB3
and it would display the 3 subcategories.. i decided that my version was just too simple and should be changed.. as i changed i noticed how "bad" my old code was.. hehe
here is version 2..
($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~, ~ and $length += 2 if ($style eq "1");
$output .= qq~<br>~ if ($style eq "2");
}
$url = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~ ~ if ($style eq "2");
$output .= qq~<a href="$url">$category_name</a>~;
$s++;
last if ($description ne "ALL" && $#subcatsub > 0);
}
}
undef $length;
if ($s < $#{$subcategories{$subcat}}) {
$output .= qq~..~ if ($style eq "1");
}
}
else { $output .= qq~$description~ if (!($description =~ /^[\s\n]*$/)); }
replace it with:
of course.. in links.cfg add this:
in site_html.pl.. it's the same thing in site_html_templates.pl except the qq~.....~; are qq|.....|;
HOW TO USE?
well.. i will get to this more detailed when i update the links mod page for it.. (sooner or later).. but here is a brief description..
still.. 2 styles..
style 1
CATEGORY (x)
subcategory1, subcategory2, subcategory3..
style 2
CATEGORY (x)
subcategory1
subcategory2
subcategory3
well.... now it doesn't need to be in alphabetical.. you can specify any order to list them..
in the description of the category.. input one of these:
(ALL)1
lists all (alphabetical.. up to subcat_length) in style 1
(ALL)2
lists all (alphabetical) in style 2
(Games|Utilities|Hacks)1
lists:
Games, Utilities, Hacks
and ".." if there are more than 3 subcategories in that category..
(Games|Utilites|Hacks)2
lists
Games
Utilities
Hacks
also.. this version will check to see if the category exists.. if not.. it skips it so it won't print a dead category..
tell me if you are successful installing it..
jerry
Recently, I've been working with an SQL version of my copy of Links2 and I have decided to just switch over.. So I am going to start releasing some mods that I never intended to release..
Starting with Subcategories Like Yahoo v2..
I made this quite awhile ago.. when a template user emailed me with an error.. he had thought it was usable like this:
SUB1, SUB2, SUB3
and it would display the 3 subcategories.. i decided that my version was just too simple and should be changed.. as i changed i noticed how "bad" my old code was.. hehe
here is version 2..
Code:
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~, ~ and $length += 2 if ($style eq "1");
$output .= qq~<br>~ if ($style eq "2");
}
$url = "$build_root_url/" . &urlencode($_) . "/";
$output .= qq~ ~ if ($style eq "2");
$output .= qq~<a href="$url">$category_name</a>~;
$s++;
last if ($description ne "ALL" && $#subcatsub > 0);
}
}
undef $length;
if ($s < $#{$subcategories{$subcat}}) {
$output .= qq~..~ if ($style eq "1");
}
}
else { $output .= qq~$description~ if (!($description =~ /^[\s\n]*$/)); }
replace it with:
Code:
$output .= qq~<dd><span class="descript">$description</span></dd>~ if (!($description =~ /^[\s\n]*$/));of course.. in links.cfg add this:
Code:
$subcat_length = 40;in site_html.pl.. it's the same thing in site_html_templates.pl except the qq~.....~; are qq|.....|;
HOW TO USE?
well.. i will get to this more detailed when i update the links mod page for it.. (sooner or later).. but here is a brief description..
still.. 2 styles..
style 1
CATEGORY (x)
subcategory1, subcategory2, subcategory3..
style 2
CATEGORY (x)
subcategory1
subcategory2
subcategory3
well.... now it doesn't need to be in alphabetical.. you can specify any order to list them..
in the description of the category.. input one of these:
(ALL)1
lists all (alphabetical.. up to subcat_length) in style 1
(ALL)2
lists all (alphabetical) in style 2
(Games|Utilities|Hacks)1
lists:
Games, Utilities, Hacks
and ".." if there are more than 3 subcategories in that category..
(Games|Utilites|Hacks)2
lists
Games
Utilities
Hacks
also.. this version will check to see if the category exists.. if not.. it skips it so it won't print a dead category..
tell me if you are successful installing it..
jerry