Sorry to keep asking you questions about this. I have made those changes you told me to, but it does still not appear to be working. Below is a copy of my build_category_pages. I thought it might help you figure out what is going wrong...
Code:
sub build_category_pages {
# --------------------------------------------------------
# This routine builds all the category pages. Each category uses
# the same template which is defined in &site_html_category.
# Modified June 26, 1999
# Fixing the bug of Prev
my ($cat, $url, $dir, @related, $relation, $page_num, $prev_page, $next_page, $numlinks);
local ($category, $links, $links2, $title_linked, $title, $total, $category_name, $category_name_escaped);
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev);
# 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? =)
$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.
($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$category{$cat}}[2..7];
# 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">|;
$related .= &build_clean($relation);
$related .= "</a> ($stats{$relation}[0])</li>";
### mod
$stats{$relation}[0]) added to display number of related links
}
# 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;
}
$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);
# Store all the category html info in $category.
if ($#{$subcategories{$cat}} >= 0) {
$category = &site_html_print_cat (@{$subcategories{$cat}});
}
else {
$category = "";
}
$numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$next = $prev = $links = "";
if (($numlinks > $build_links_per_page) && $build_span_pages) {
$total_pages=(int($numlinks/$build_links_per_page)); #added
if ($total_pages < $numlinks/$build_links_per_page) {$total_pages++}
$next .= "<b>1</b>"; # new added
for $j(2..($total_pages)){ #added & changed
$next .= qq~ <a href="more$j$build_extension">$j</a>~; #added
} # end of for #added
$page_num = 2;
$next .= qq~ <a href="more$page_num$build_extension">[Next >>]</a>~; #added
for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp) if ($i <= int($#{$links{$cat}}/2));
$links2 .= &site_html_two (%tmp) if ($i > int($#{$links{$cat}}/2));
}
@{$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);
####$links .= &site_html_link (%tmp) if ($i <= int($#links/2));
$links .= &site_html_link (%tmp) if ($i <= int($#{$links{$cat}}/2));
$links2 .= &site_html_two (%tmp) if ($i > int($#{$links{$cat}}/2));
}
}
# 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.
while ($next && $build_span_pages) {
if ($numlinks > $build_links_per_page) {
$prev=$next=$next_page=$prev_page=""; #added
$next_page = $page_num+1;
$prev_page = $page_num-1; #added
if ($page_num == 2){
$prev .= qq~ <a href="$url">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url"> 1</a> ~;}
else {$prev .= qq~ <a href="more$prev_page$build_extension">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url">1</a> ~;
for $k(2..$prev_page){$prev .= qq~ <a href="more$k$build_extension">$k</a>~;}}
$next .= qq~ <b>$page_num</b> ~; #added
for $m($next_page..$total_pages){$next .= qq~ <a href="more$m$build_extension">$m</a>~;}
$next .= qq~ <a href="more$next_page$build_extension">[Next >>]</a>~; #added
} # end of if
else {
if ($page_num == $total_pages) {
$prev = $next = $next_page = $prev_page= "";
$prev_page=$total_pages-1;
if ($page_num == 2){
$prev .= qq~ <a href="$url">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url"> 1</a> ~;}
else {$prev .= qq~ <a href="more$prev_page$build_extension">[<< Prev]</a> ~;
$prev .= qq~ <a href="$url">1</a> ~;
for $k(2..$prev_page){$prev .= qq~ <a href="more$k$build_extension">$k</a>~;}
} # end of else
$prev .= qq~ <b>$page_num</b> ~; #added
} # end of if
} # end of else
$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) if ($i <= int($#{$links{$cat}}/2));
$links2 .= &site_html_two (%tmp) if ($i > int($#{$links{$cat}}/2));
}
$title_linked = &build_linked_title ("$cat/Page_$page_num/");
$title = &build_unlinked_title ("$cat/Page_$page_num/");
$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);
if ($page_num == $total_pages) { last; }
else { $page_num++; }
}
print "\n";
}
}
There is one thing that is different this time though. As I mentioned previously, I have $links2 now pointing to site_html_two which prints out something like BBBLO (just something different to HELLO). However, when I took $links2 out $site_html_category, it printed BBBLO, so somehow $links is pointing to $site_html_two. I hope that makes sense.