I currently don't have this nav sysytem in place, but I did before, and I'm pretty sure it worked OK. Check out this code from nph-build.pl:
[See also,
http://www.gossamer-threads.com/...g=nonenglish;#235342]
sub build_category_pages {
# --------------------------------------------------------
# This routine builds all the category pages. Each category uses
# the same template which is defined in &site_html_category.
my $build_single = shift;
my ($cat, $url, $dir, @related, $relation, $page_num, $next_page, $numlinks);
local ($category, $links, $title_linked, $title, $total, $category_name, $category_name_escaped);
# ***************************************** nonenglish modification - begin ****************
# local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev);
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $nonenglish, $next, $prev);
# ***************************************** nonenglish modification - end ******************
# Go through each category and build the appropriate page.
CATEGORY: foreach $cat (sort keys %category) {
########################################################
#LT replaced this with next two lines: CATEGORY: foreach $cat (sort keys %category) {
#1 sub byfield { $category{$a}[$cat_sort_field] <=> $category{$b}[$cat_sort_field] };
#2 CATEGORY: foreach $cat (sort byfield @cat) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)
next CATEGORY if ($build_single and ($build_single ne $cat));
$url = "$build_root_url/" . &urlencode($cat) . "/";
$use_html ?
print qq|Building Category: <A HREF="$url" TARGET="_blank">$cat</A>\n| :
print qq|Building Category: $cat\n|;
print "\tSubcategories: " . ($#{$subcategories{$cat}} + 1) . "\n";
print "\tLinks: " . (($#{$links{$cat}}+1) / ($#db_cols+1)) . "\n";
# Let's make sure the directory exists, build it if it doesn't.
$dir = &build_dir ($cat);
print "\tDirectory: $dir\n";
print "\tFilename : $dir/$build_index\n";
# We set up all the variables people can use in &site_html.pl.
# ***************************************** nonenglish modification - begin ****************
# ($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$category{$cat}}[2..7];
($description, $related, $meta_name, $meta_keywords, $header, $footer, $nonenglish) = @{$category{$cat}}[2..8];
# ***************************************** nonenglish modification - end ******************
# Calculate the related entries and put in a <LI> list.
@related = split(/\Q$db_delim\E/, $related); $related = "";
foreach $relation (@related) {
$related .= qq|<li><a href="$build_root_url/|;
$related .= &urlencode($relation);
$related .= qq|/$build_index">|;
# ***************************************** nonenglish modification - begin ****************
# $related .= &build_clean($relation);
$related .= &kategorie_title_mb($relation);
# ***************************************** nonenglish modification - end ******************
$related .= "</a></li>";
}
# Get the header and footer from file if it exists, otherwise assume it is html.
if ($header && (length($header) < 20) && ($header !~ /\s+/) && (-e "$db_header_path/$header")) {
open (HEAD, "<$db_header_path/$header") or &cgierr ("Unable to open header file: $db_header_path/$header. Reason: $!");
$header = "";
while (<HEAD>) {
$header .= $_;
}
close HEAD;
}
if ($footer && (length($footer) < 20) && ($footer !~ /\s+/) && (-e "$db_footer_path/$footer")) {
open (FOOT, "<$db_footer_path/$footer") or &cgierr ("Unable to open footer file: $db_footer_path/$footer. Reason: $!");
$footer = "";
while (<FOOT>) {
$footer .= $_;
}
close FOOT;
}
# ***************************************** nonenglish modification - begin ****************
# $title_linked = &build_linked_title ($cat);
# $title = &build_unlinked_title ($cat);
# $total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
# $category_name = $cat;
# $category_name_escaped = &urlencode ($cat);
# $category_clean = &build_clean ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
##!!begin nonenglish fix************************** @categorylist = split (m:/:, $cat);
$depth_new = $#categorylist;
if ($depth_old >= $depth_new) {
for ($i = $depth_new; $i <= $depth_old; $i++) {
pop(@kategorylist);
}
}
$depth_old = $depth_new;
if ($nonenglish eq "") {
push(@kategorylist, $categorylist[$#categorylist]);
$title_linked = &build_linked_title ($cat);
$title = &build_unlinked_title ($cat);
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);
}
else {
push(@kategorylist, $nonenglish);
$nonenglishfull = join('/', @kategorylist);
$title_linked = &build_linked_title_mb ($cat, $nonenglishfull);
$title = &build_clean_mb ($cat, $nonenglishfull);
##XXXXXXXXXXXXXXXXXXXXXXXXXXXXX^^^^^^^^
$category_name = &build_last_title_mb ($nonenglish);
$category_name_escaped = &build_last_title_mb ($nonenglish);
$category_clean = &build_clean_mb ($nonenglish);
} ##!!End fix**************************** # ***************************************** nonenglish modification - end ******************
# Store all the category html info in $category.
if ($#{$subcategories{$cat}} >= 0) {
$category = &site_html_print_subcat (@{$subcategories{$cat}});
}
else {
$category = "";
}
# If we are spanning pages, we grab the first x number of links and build
# the main index page. We set $numlinks to the remaining links, and we remove
# the links from the list.
$numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$next = $prev = $links = "";
if (($numlinks > $build_links_per_page) && $build_span_pages) {
$page_num = 2;
$next = $url . "more$page_num$build_extension";
for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);
}
@{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}];
$numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1);
}
# Otherwise we either only have less then x number of links, or we are not
# splitting pages, so let's just build them all.
else {
for ($i = 0; $i < $numlinks; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);
}
}
# Create the main page.
open (CAT, ">$dir/$build_index") or &cgierr ("unable to open category page: $dir/$build_index. Reason: $!");
print CAT &site_html_category;
close CAT;
# Then we go through the list of links and build on the remaining pages.
$prev = $url if ($build_span_pages);
while ($next && $build_span_pages) {
if ($numlinks > $build_links_per_page) {
$next_page = $page_num+1;
$next = $url . "more$next_page$build_extension";
}
else {
$next = "";
}
$links = "";
LINK: for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
last LINK if ($tmp{$db_key} eq "");
$links .= &site_html_link(%tmp);
}
# ***************************************** nonenglish modification - begin ****************
# $title_linked = &build_linked_title ("$cat/Page_$page_num/");
# $title = &build_unlinked_title ("$cat/Page_$page_num/");
if ($nonenglish eq "") {
$title_linked = &build_linked_title ("$cat/Page_$page_num/");
$title = &build_unlinked_title ("$cat/Page_$page_num/");
}
else {
##!!begin nonenglish fix************************
$title_linked = &build_linked_title_mb ("$cat/Page_$page_num/", "$nonenglish\\Page $page_num\\");
$title = &build_clean_mb ("$nonenglish\\Page $page_num\\");
}
##!!end fix******************** # ***************************************** nonenglish modification - end ******************
$use_html ?
print qq|\tSubpage : <A HREF="|, $url, qq|more$page_num$build_extension" TARGET="_blank">$dir/more$page_num$build_extension</A>\n| :
print qq|\tSubpage : $dir/more$page_num$build_extension\n|;
open (CAT, ">$dir/more$page_num$build_extension") or &cgierr ("unable to open category page: $dir/index$page_num$build_extension. Reason: $!");
print CAT &site_html_category;
close CAT;
@{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}];
$numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1);
$prev = $url . "more$page_num$build_extension";
$page_num++;
}
print "\n";
}
}
And these may or not be different than what you have:
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;
}
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 class="smallnav" href="$build_root_url/top">Top</a> »|;
foreach $dir (@dirs) {
$path .= "/$dir";
$desc = shift (@descs);
$output .= qq| <a class="smallnav" href="$build_root_url$path/">$desc</a> »|;
}
$output .= " $last";
return $output;
}
Leonard
aka PerlFlunkie