OK, fixed it!
Instead of all the above, put this new sub in
db_utils.pl:
Code:
# > Abbreviated Description mod sub teaser { # ----------------------------------------------- # This creates a shortened description. my $msg = $tease;
my $max = 6; # You can set the word count here.
my @cuts = split / /, $msg; if ($#cuts <= $max) {
return $msg;
}
else {
my $snip;
for (my $i = 0; $i < $max; $i++) {
$snip .= " ". $cuts[$i];
}
$back .= qq~...<a href="$build_detail_url/$tmp{'ID'}$build_extension">[more]</a>~;
return $snip;
} } # < Abbreviated Description mod Then in
nph-build.cgi, sub build_category_pages, add these:
Code:
# 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}});
# > Abbreviated Description mod $tease = $tmp{Description};
$tmp{Description} = &teaser; # < Abbreviated Description mod $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}});
# > Abbreviated Description mod $tease = $tmp{Description};
$tmp{Description} = &teaser; # < Abbreviated Description mod $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}});
# > Abbreviated Description mod $tease = $tmp{Description};
$tmp{Description} = &teaser; # < Abbreviated Description mod last LINK if ($tmp{$db_key} eq "");
$links .= &site_html_link (%tmp);
}
That will take care of the category pages. For New and Cool, do this (Rated does not use the description field)...
In
sub_build_new_page:
Code:
# Now we go through all the new_links (which are organized by category), and
# build the html in array indexed by date then category.
$total = 0;
CATEGORY: foreach $category (sort keys %new_links) {
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
# > Abbreviated Description mod
$tease = $tmp{Description};
$tmp{Description} = &teaser;
# < Abbreviated Description mod ${$link_output{$tmp{'Date'}}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp{'Date'}}++;
}
}
In
sub build_cool_page:
Code:
LINK: for ($i = 0; $i < ($#{$cool_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$cool_links{$category}});
# > Abbreviated Description mod
$tease = $tmp{Description};
$tmp{Description} = &teaser;
# < Abbreviated Description mod $link_output{$category} .= &site_html_link (%tmp) . "\n";
}
In
search.cgi, sub main:
Code:
# Go through each category of links returned, and build the HTML. Store in hash %link_output.
SETOFLINKS: foreach $setoflinks (sort keys %link_results) {
my $hits = ($#{$link_results{$setoflinks}} + 1) / ($#db_cols+1);
LINK: for ($i = 0; $i < $hits; $i++) {
$link_hits++;
if (($link_hits <= $highrange) && ($link_hits >= $lowrange)) {
%tmp = &array_to_hash ($i, @{$link_results{$setoflinks}});
# > Abbreviated Description mod
$tease = $tmp{Description};
$tmp{Description} = &teaser;
# < Abbreviated Description mod $link_output{$setoflinks} .= &site_html_link (%tmp) . "\n";
}
}
}
If you have any trouble, let me know!
Leonard
aka PerlFlunkie