Gossamer Forum
Home : Products : Links 2.0 : Customization :

Span Pages for New, Cool, Top pages

(Page 2 of 2)
> >
Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
I have now written a second version of the mod for those who like to use the original way of listing the cool page - with categories.

You can now retain the category headings before the cool links in each category, and the pages span correctly with the exact
number of links per page.

You only have to modify sub build_cool_page in nph-build.cgi - so it's very simple.Smile

Just replace your existing sub build_cool_page with the following: -

Code:
sub build_cool_page {
# --------------------------------------------------------
# Creates spanned "What's Cool" pages.
local ($total, $hits, $percent, $link_results, $title_linked, $title, $next, $prev);
my (%link_output, $category_clean, $url, $page_num, $prev_page, $next_page, $numlinks);

if ($build_cool_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}

$total = 0;
$numlinks = 0;<p> CATEGORY: foreach $category (sort keys %cool_links) {
LINK: for ($i = 0; $i < ($#{$cool_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
}
}<p> $numlinks = $total;<p> $title_linked = &build_linked_title ("Cool");
open (COOL, ">$build_cool_path/$build_index") or cgierr ("unable to open what's cool page: $build_cool_path/$build_index. Reason: $!");
print "\tCool Links: $total\n";
($db_popular_cutoff < 1) ?
($percent = $db_popular_cutoff * 100 . "%") :
($percent = $db_popular_cutoff);
close COOL;
$url = $build_cool_url;<p> $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; <p> foreach $category (sort keys %cool_links) {
$category_clean = &build_clean ($category);
if ($i < $build_links_per_page) {
LINK: for ($q = 0; $q < ($#{$cool_links{$category}}+1) / ($#db_cols + 1); $q++) {
if ($i < $build_links_per_page) {
%tmp = &array_to_hash ($q, @{$cool_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;
}<p># Otherwise we either only have less then x number of links, or we are not
# splitting pages, so let's just build them all.<p> else {
foreach $category (sort keys %cool_links) {
$category_clean = &build_clean ($category);
LINK: for ($q = 0; $q < ($#{$cool_links{$category}}+1) / ($#db_cols + 1); $q++) {
%tmp = &array_to_hash ($q, @{$cool_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
}<p> $link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
$link_results .= $link_output{$category};
}
}<p># Create the main page.
open (COOL, ">$build_cool_path/$build_index") or &cgierr ("unable to open what's cool page: $build_cool_path/$build_index. Reason: $!");
print COOL &site_html_cool(@cool_links);
close COOL;<p># 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 %cool_links) {
if (($s > $r) && ($i < $build_links_per_page)) {
$category_clean = &build_clean ($category);
$link_output{$category} = "";
LINK: for ($q = $t; $q < ($#{$cool_links{$category}}+1) / ($#db_cols + 1); $q++) {
if ($i < $build_links_per_page) {
%tmp = &array_to_hash ($q, @{$cool_links{$category}});
$link_output{$category} .= &site_html_link (%tmp) . "\n";
$i++;
$t = 0;<p> }
else {
$r--;
$t = $q;
last; }<p>
}<p>
$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_cool_path/more$page_num$build_extension</A>\n| :
print qq|\tSubpage : $build_cool_path/more$page_num$build_extension\n|;

open (COOL, ">$build_cool_path/more$page_num$build_extension") or &cgierr ("unable to open what's cool page: $build_cool_path/index$page_num$build_extension. Reason: $!");
print COOL &site_html_cool(@cool_links);
close COOL;
$p++;
$numlinks = $numlinks - $i;
if ($page_num == $total_pages) { last; }
else { $page_num++; }
}
print "\n";
}


Then add the "prev => $prev" and "next => $next" lines to site_html_templates.pl under sub site_html_cool like this: -

Code:
sub site_html_cool {
# --------------------------------------------------------
# This routine will build a what's cool page. <p> return &load_template ('cool.html', {
total => $total,
grand_total => $grand_total,
percent => $percent,
prev => $prev,
next => $next,
link_results => $link_results,
title_linked => $title_linked,
%globals
} );
}


and finally add the tags to the cool.html template above and below the link results like this: -

Code:
<center>
<%if prev%>
<%prev%>
<%endif%>

<%if next%>
<%next%>
<%endif%>
</center>

<%link_results%>

<center>
<%if prev%>
<%prev%>
<%endif%>

<%if next%>
<%next%>
<%endif%>
</center>


Warwick.

------------------
HumorLinks Comedy Search, Humor DVD and Video Store

http://www.humorlinks.com

humorlinks@humorlinks.com


Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
You should post the codes in the Resource Center, so they will not get lost in the shuffle.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Post deleted by humorlinks In reply to
Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
I submitted the codes for this mod to the Resource Center
on 9th May - but so far they have still not been added.

Those who wish to access them directly, please visit: -

http://www.humorlinks.com/...um2/HTML/000003.html

Regards,

Warwick.


http://www.humorlinks.com
Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
After those of Cool Page is solved,
is there any new development about the Span Pages for New Page, or Editoral Pick Page ?


Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
I tried using this for New pages by changing all COOL to NEW, Cool to New, and cool to new, but no luck. In fact, nph-build.cgi would not respond when clicked in admin - nothing happened. Has anyone had any luck with this?

Many thanks.

Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
I would like to apply this to the top rated page, but I'm a little lost.

Has anyone spanned the Top Rated page already?

I'm wondering if anyone can walk me though modifying the spanning Cool links mod by humorlinks so it can be applied to the Top Rated Page.

Thanks in advance for any pointers.

Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
I don't know how relevant this is, but should <p> be showing in the script such as:

$numlinks = 0;<p> CATEGORY: foreach $category (sort keys %cool_links) { LINK: for ($i = 0; $i < ($#{$cool_links{$category}}+1) / ($#db_cols + 1); $i++) { $total++; } }<p> $numlinks = $total;<p> $title_linked = &build_linked_title ("Cool");

I saw these in a couple places and just wanted to check...thanks for the work you put into this one humorlinks!

Perl Hopefull
Quote Reply
Re: Span Pages for New, Cool, Top pages In reply to
Those <p> tags would cause errors.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: [humorlinks] Span Pages for New, Cool, Top pages In reply to
Quote:
and finally add the tags to the cool.html template




This works great but I'm not using templates so the Next / Prev does not show at the bottom of my pages. Is there something I can add to site_html.cgi?



Thanks
Quote Reply
Re: [MJB] Span Pages for New, Cool, Top pages In reply to
Use $next $prev variables rather than the template codes of <%next%> <%prev%>...might want to consider using templates...they're easier to edit and also involve less Perl knowledge and coding.
========================================
Buh Bye!

Cheers,
Me
> >