For the purposes of this mod I used the @ symbol as the key. You can probably use any symbol, but you want to choose one that you will not use in category names for anything other than this mod.
To start with if you don't already have Bobsie's Select Category list mod installed (
goodstuff.orphanage.com/rcat_mod.html ) You will want to install it.
Once you've installed that you'll want to make a Modification to his
site_html_cat_select_list(The change in the code is Bolded):
Code:
sub site_html_cat_select_list {
# --------------------------------------------------------
# This routine builds the options for the category select list.
my (@subcat) = @_;
my $output;
CAT: foreach $subcat (sort @subcat) {
if (@exclude_categories) {
foreach (@exclude_categories) {
($subcat eq $_ | | $subcat =~ /\@$/) and next CAT; #Prevents visitors from adding to categories with the @ symbol
}
}
$category_name = &build_clean($subcat);
$output .= qq| <option value="$subcat">$category_name\n|;
}
return $output;
}
NOTE: in the changed line there are two pipes ( | | ) there should be no space inbetween them The change here prevents visitors from adding to categories that contain the @ symbol.
Next open the nph-build.cgi and find the
sub build_category_pages {. Add the Bolded line into the code
Code:
# Go through each category and build the appropriate page.
CATEGORY: foreach $cat (sort keys %category) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)
next CATEGORY if ($cat =~ "@"); #Prevents Categories with the @ symbol from being Built next CATEGORY if ($build_single and ($build_single ne $cat));
This change skips the categories with the @ symbol in the category page building process.
To display the new category format and link it to the desired category open your site_html_templates.pl(if you don't use templates this should work in the site_html.pl too, but I have not done it). In the
sub site_html_print_cat { Replace this...
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> |;
With this...
Code:
# Then we print out the name linked, new if it's new, and popular if its popular.
if ($category_name=~ "@") {
$output .= qq|<dl><dt><strong><a class="link" href="$build_root_url/$description/">$category_name</a></strong> |;
}
else {
$output .= qq|<dl><dt><strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
}
Now to edit the desired category you want to work with this mod. Say you want the Category Internet/Games to refer visitors to Games/Internet. In the admin Add/modify a category window change the name of the Category Internet/Games by adding the @ sign to the end of it...
Internet/Games@
Then in the Description type the name of the Category you are referring it to..
Games/Internet
Note: Don't add begining or trailing slashes. This next part is only for people who have installed Widgetz's Subcategories like Yahoo mod(I don't know the URL, but I think it's in the Resource Center). As I found out, sometimes one of the modified categories will show up in the subcategories display. Even though the modified category is set up right, when displayed under it's main category it wants to link as if it were normal. I had two choices...
1. Use a If/else statment in widgets mod like the one used above in the
sub site_html_print_cat to get it to link right, or
2. Don't let the modified categories to be displayed at all in this mod.
I choose to do the second option. In Widgetz's mod he places the following bit of code in the
sub site_html_print_cat. Add the Bolded line into that code.
Code:
if ($#{$subcategories{$subcat}} >= 0 && $description =~ /^SUB.*/) {
$v = 0;
$sub_length = "";
$output .= qq| |;
foreach $subcatsub (sort @{$subcategories{$subcat}}) {
next if ($subcatsub=~ "@"); $suburl = "$build_root_url/" . &urlencode($subcatsub) . "/";
if ($subcatsub =~ m,.*/([^/]+)$,) { $subcategory_name = &build_clean($1); }
else { $subcategory_name = &build_clean($subcatsub); }
$sub_length .= qq|, | if ($description =~ /1$/ && $v ne "0");
$sub_length .= qq|$subcategory_name| if ($description =~ /1$/);
if ($description =~ /1$/ && length($sub_length) > $subcat_length) {
$output .= qq|...|;
last;
}
else {
$output .= qq|, | if ($description =~ /1$/ && $v ne "0");
$output .= qq| | if ($description =~ /2$/ | | $v eq "0");
$output .= qq| | if ($description =~ /2$/);
$output .= qq|<a href="$suburl">$subcategory_name</a>|;
$v++;
}
}
$output .= qq| |;
}
else {
$output .= qq|$description| if (!($description =~ /^[\s\n]*$/));
}
This is my first attempt at making and posting a mod I hope I explained it well and didn't leave anything out. If you install this please let me know how it works, especially if there are any problems.
Sheldon
[This message has been edited by PlanetSheldon (edited July 31, 1999).]
[This message has been edited by PlanetSheldon (edited July 31, 1999).]