Gossamer Forum
Home : Products : Links 2.0 : Customization :

Page: 1 2 3 4

Quote Reply
Page: 1 2 3 4
   
how can i make in Categories pages like this:
Page: 1 2 3 4 5 6 7 8 9 ... 459


Quote Reply
Re: [marcc] Page: 1 2 3 4 In reply to
I have posted some code I used on my site, which makes it easier to see what to change (NSPm = Numbered Span Pages mod):


nph-build.cgi

sub build_category_pages {
# --------------------------------------------------------
# This routine builds all the category pages. Each category uses
# the same template which is defined in &site_html_category.

... edited for space ...

# 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);
# > Numbered Span Pages mod (NSPm)
$next = $prev = $links = $more_cat_pages = "";
# $next = $prev = $links = "";
# < NSPm

if (($numlinks > $build_links_per_page) && $build_span_pages) {
$page_num = 2;
$next =
# NSPm >
# Lets calculate the total number pages we have
$tmp_total_pages = $numlinks/$build_links_per_page;
$total_pages = int($numlinks/$build_links_per_page);
if ($tmp_total_pages > $total_pages) {
$total_pages++
}
#Build the toolbar
$more_cat_pages = "<p align=\"center\">1 ";
for ($i = 1; $i < $total_pages; $i++) {
$tmp_i = $i + 1;
$more_cat_pages .= "<a href=\"more$tmp_i$build_extension\">$tmp_i</a> ";
}
$more_cat_pages .= "<a href=\"more$page_num$build_extension\">[>>]</a>";
$more_cat_pages .= "</p>";
$next = $url . "more$page_num$build_extension";
# < NSPm

##$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 = "";
}
# NSPm >
#Build the toolbar
if ($page_num eq 2) {
$more_cat_pages = "<p align=\"center\"><a href=\"$build_index\">[<<]</a> <a href=\"$build_index\">1</a> ";
}
else {
$tmp_page_num = $page_num-1;
$more_cat_pages = "<p align=\"center\"><a href=\"more$tmp_page_num$build_extension\">[<<]</a> <a href=\"$build_index\">1</a> ";
}
for ($i = 1; $i < $total_pages; $i++) {
$tmp_i = $i + 1;
if ($tmp_i ne $page_num) {
$more_cat_pages .= "<a href=\"more$tmp_i$build_extension\">$tmp_i</a> ";
}
else {
$more_cat_pages .= "$tmp_i ";
}
}
if ($page_num < $total_pages) {
$more_cat_pages .= "<a href=\"more$next_page$build_extension\">[>>]</a>";
}
$more_cat_pages .= "</p>";
# < NSPm
# Build the links
$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);
}

... edited for space ...


==========

In site_html_templates.pl, in sub site_html_category, what you add is this:

more_cat_pages => $more_cat_pages,


=========

Then put this in your category.html template:

<!-- More Pages -->
<%if more_cat_pages%>
<%more_cat_pages%>
<%endif%>



=========

This thread has the code:

http://www.gossamer-threads.com/...cgi?post=32766#32766



Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: Dec 7, 2004, 8:32 PM