Well, I finally decided to have a go at it. Using the bits of info on the thread
http://www.gossamer-threads.com/...orum.cgi?post=148165, I managed to redo the spanning editor's picks mod. I'm still in disbelief, but it actually works. For anyone who is using editor's picks, this is what I did:
In
nph-build.cgi replace the build_pick_page subroutine with the following codes:
sub build_pick_page {
# --------------------------------------------------------
# Creates spanned "Editor's Pick" pages.
local ($total, $link_results, $title_linked, $title, $next, $prev);
my (%link_output, $category_clean, $url, $page_num, $prev_page, $next_page, $numlinks);
if ($build_pick_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;
$numlinks = 0;
CATEGORY: foreach $category (sort keys %pick_links) {
LINK: for ($i = 0; $i < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$pick_links{$category}});
}
}
$numlinks = $total;
$title_linked = &build_linked_title ("Pick");
open (PICK, ">$build_pick_path/$build_index") or cgierr ("unable to open picks page: $build_pick_path/$build_index. Reason: $!");
print "\tEditor's Picks: $total\n";
close PICK;
$url = $build_pick_url;
$next = $prev = $link_results = "";
if (($numlinks > $build_links_per_page) && $build_span_pages) {
$total_pages=(int($numlinks/$build_links_per_page));
if ($total_pages < $numlinks/$build_links_per_page) {$total_pages++}
$next .= "<b>1</b>"; # new added
for $j(2..($total_pages)){
$next .= qq~ <a href="more$j$build_extension">$j</a>~;
} # end of for #added
$page_num = 2;
$next .= qq~ <a href="more$page_num$build_extension">[Next >>]</a>~;
$p = 1;
$t = 0;
$i = 0;
$r = 0;
foreach $category (sort keys %pick_links) {
$category_clean = &build_clean ($category);
if ($i < $build_links_per_page) {
LINK: for ($q = 0; $q < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $q++) {
if ($i < $build_links_per_page) {
%tmp = &array_to_hash ($q, @{$pick_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
$i++;
}
else {
$r--;
$t = $q;
last; }
}
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
$r++;
}
}
$p++;
$numlinks = $numlinks - $i;
}
# 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 {
foreach $category (sort keys %pick_links) {
$category_clean = &build_clean ($category);
LINK: for ($q = 0; $q < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $q++) {
%tmp = &array_to_hash ($q, @{$pick_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
}
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
}
}
# Create the main page.
open (PICK, ">$build_pick_path/$build_index") or &cgierr ("unable to open editor's pick page: $build_pick_path/$build_index. Reason: $!");
print PICK &site_html_pick(@pick_links);
close PICK;
# 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="";
$next_page = $page_num+1;
$prev_page = $page_num-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>~;}}
$next .= qq~ <b>$page_num</b> ~;
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>~;
} # 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> ~;
} # end of if
} # end of else
$link_results = "";
$i = 0;
$s = 1;
foreach $category (sort keys %pick_links) {
if (($s > $r) && ($i < $build_links_per_page)) {
$category_clean = &build_clean ($category);
$link_output{$category} = "";
LINK: for ($q = $t; $q < ($#{$pick_links{$category}}+1) / ($#db_cols + 1); $q++) {
if ($i < $build_links_per_page) {
%tmp = &array_to_hash ($q, @{$pick_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
$i++;
$t = 0;
}
else {
$r--;
$t = $q;
last; }
}
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
$r++;
}
$s++;
}
$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">$build_pick_path/more$page_num$build_extension</A>\n| :
print qq|\tSubpage : $build_pick_path/more$page_num$build_extension\n|;
open (PICK, ">$build_pick_path/more$page_num$build_extension") or &cgierr ("unable to open editor's pick page: $build_pick_path/index$page_num$build_extension. Reason: $!");
print PICK &site_html_pick(@pick_links);
close PICK;
$p++;
$numlinks = $numlinks - $i;
if ($page_num == $total_pages) { last; }
else { $page_num++; }
}
print "\n";
}
The rest is given in the other thread, below:
Add these codes to your
pick.html template:
Code:
<%if prev%>
<%prev%>
<%endif%>
<%if next%>
<%next%>
<%endif%>
and the following to
sub site_html_pick in site_html_templates.pl:
Code:
prev => $prev,
next => $next,
Whoosh. I'm glad that's done.Kathy