I’m having problem with pagination. On the main page, the numbering has reached 21 and from 1 to 21 there are all numbers between. The word “back†now has slipped into the second row, because the first line is so: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Can somebody help to stop “marching of numbers�
Comments
it currently reads:
` for ($i=1; $i <= $total; $i++) {<br />
echo "n ";
printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));
echo "";
}`
I would change the first line to:
` for $i=(min(1,$current-5); $i < max($total, ($current+5)); $i++) {`
This should limit the page numbers to those close to the current page.
Note: I have not tried this!!!!
It doesn’t work. The gallery disappears.
it should read
`for ($i=min(1,$current-5); $i < max($total, ($current+5)); $i++) {`
I put the code in, but it still doesn't work, looks so: -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
` for ($i=max(1, ($current-5)); $i <= min($total,($current+5)); $i++) {`
would be even better.
It now works somehow, but doesn’t look like a “classic†pagination.
Under this code: `for ($i=max(1, ($current-5)); $i <= min($total,($current+5)); $i++) {`
it is so: 1 2 3 4 5 6
And under this one: `for ($i=($j=max(1, $current-5)); $i <= min($total, $j+11); $i++) {`
it is so: 1 2 3 4 5 6 7 8 9 10 11 12
Problem is that the last page is missing and the surfer can’t realize it. Is it possible to add such an element, e.g. (Last Page), or put a break between numbers, e.g. 1 2 3... 18 19 20 . Thanks.
` for ($i=($j=max(1, $current-5)); $i <= min($total, $j+11); $i++) {<br />
echo "n ";
printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));
echo "";
}`
with
` for ($i=($j=max(1, $current-2)); $i <= min($total, $j+5); $i++) {<br />
echo "n ";
printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));
echo "";
}
if ($i < ($total-2)) {echo "n " . ". . ." . ""; }
for ($i=max($i+1, $total-2); $i <= $total; $i++) {<br />
echo "n ";
printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));
echo "";
}`
and let me know how it looks.
Here is the complete function:
`function printPageListWithNav($prevtext, $nexttext, $nextprev=true, $class="pagelist", $id=NULL) {
echo "
$total = getTotalPages();
$current = getCurrentPage();
echo "\n
";- ";
";- ";
";- " . ". . ." . "
"; }- ";
";- ";
";
";if ($nextprev) {
echo "\n
printPrevPageLink($prevtext, "Previous Page");
echo "
}
for ($i=($j=max(1, $current-2)); $i <= min($total, $j+5); $i++) {<br />
echo "\n
printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));
echo "
}
if ($i < ($total-2)) {echo "n
for ($i=max($i+1, $total-2); $i <= $total; $i++) {<br />
echo "\n
printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));
echo "
}
if ($nextprev) {
echo "\n
printNextPageLink($nexttext, "Next Page");
echo "
}
echo "\n
echo "\n
}`
and copy the code from the included files.
The original code I have there is:
`function printPageListWithNav($prevtext, $nexttext, $nextprev=true, $class="pagelist", $id=NULL) {
echo "
$total = getTotalPages();
$current = getCurrentPage();
echo "\n
";- ";
- ";
- ";
if ($nextprev) {
echo "\n
printPrevPageLink($prevtext, "Previous Page");
echo "";
}
for ($i=1; $i <= $total; $i++) {<br />
echo "\n
printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));
echo "";
}
if ($nextprev) {
echo "\n
printNextPageLink($nexttext, "Next Page");
echo "";
}
echo "\n";
echo "\n
}`