Gossamer Forum
Home : Products : Links 2.0 : Customization :

How to put the number of pages in a category?

Quote Reply
How to put the number of pages in a category?
   How to do this?
For example. The category Computers has 5 pages of links.
Is possible to display Page 1 of 5, then Page 2 of 5 ...???
Quote Reply
Re: How to put the number of pages in a category? In reply to
err

find this:

Code:
}
# Print out the HTML results.
&site_html_search_results;
}

right before it put:

Code:
$pagenumber = $page;
$page_of = int($link_hits/$maxhits) + 1;

if you use templates.. in site_html_templates.pl find

sub site_html_search_results {

after the code:

Code:
link_hits => $link_hits,

add

Code:
pagenumber => $pagenumber,
page_of => $page_of,

in search_results.. anywhere you want.. put

Code:
Page <%pagenumber%> of <%page_of%>

otherwise if you don't use templates.. in site_html.pl sub site_html_search_results

just add

Code:
Page $pagenumber of $page_of

hope that helps

jerry
Quote Reply
Re: How to put the number of pages in a category? In reply to
widgetz,if i change that around a little, would that work for links in search results

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
Quote Reply
Re: How to put the number of pages in a category? In reply to
Thank you guys, but what I want is to dysplay it in all the categories page and not in the search results..
It worke except the $page variable doesnīt exists!!

I will try and find the correct variable.

Do you know how to do the same above but in the categories?
Quote Reply
Re: How to put the number of pages in a category? In reply to
oh oops! that was for the search results! HAHA Smile

i'll do another one for categories.. hold on

heh.. jerry
Quote Reply
Re: How to put the number of pages in a category? In reply to
hi..

i messed up and that code was for search results! Smile

ok.. for category pages...

find this code in nph-build.cgi... sub build_category_pages

Code:
# 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;

add this before it

Code:
$pagenumber = $page_num;
$page_of = $total_pages;

also go down a little and find:

Code:
$links = "";
$l = 0;
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);
}

and add this before it..

Code:
$pagenumber = $page_num;
$page_of = $total_pages;

if you use templates.. in site_html_templates.pl find

sub site_html_category {

find:

Code:
build_links_per_page => $build_links_per_page,

add this after:

Code:
pagenumber => $pagenumber,
page_of => $page_of,

then in category.html put this wherever..

Page <%pagenumber%> of <%page_of%>

or if you don't use templates..


just put this anywhere in sub site_html_category in site_html.pl

Page $pagenumber of $page_of
Quote Reply
Re: How to put the number of pages in a category? In reply to
Thank you widgetz, but itīs not working properly.

The problems are:
The variable $total_pages does not exists anywhere.
If there is no subpage, $page_num is null

I tried the following code:

$pagenumber = $page_num -1;
$page_of = int ($numlinks/$build_links_per_page)+1; #$total_pages;
if (!$pagenumber) { $pagenumber=1; }
elsif ($pagenumber == "-1") { $pagenumber=1; }

It worked a litle better, but the $page_of is not correct. If I have ten pages, its number is 9. Itīs always 1 less..

Another solution?
Quote Reply
Re: How to put the number of pages in a category? In reply to
oh hehe.. it's cause i installed the i have the span page mod. .that's where total pages came from Smile

jerry
Quote Reply
Re: How to put the number of pages in a category? In reply to
Actually, the 1st one works to tell you how many pages in your search but it doesn't tell you your count. It would work for categories if it wasn't for the division. I can figure it out, because the one he wants works for me, and the one i want won't work.

------------------
------------------------------------------
Lavon Russell
LookHard! Search
http://www.lh.yi.org
Quote Reply
Re: How to put the number of pages in a category? In reply to
   

[This message has been edited by Bmxer (edited July 21, 1999).]
Quote Reply
Re: How to put the number of pages in a category? In reply to
do this

Code:
$page_of=(int($numlinks/$build_links_per_page));
if ($page_of < $numlinks/$build_links_per_page) { $page_of++; }

that should do it Smile [for page_of of course]