Member
Member
llapa   2007-07-09, 03:58
#1
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”?
Member
Member
sbillard   2007-07-09, 18:32
#2
The code which generates this list is the function printPageListWithNav in template-functions.php

it currently reads:
` for ($i=1; $i <= $total; $i++) {

echo "n <li" . (($i == $current) ? " class="current"" : "") . ">";

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.

[b]Note:[/b] I have not tried this!!!!
Member
Member
llapa   2007-07-10, 12:06
#3
sbillard, thanks for the replay.
It doesn’t work. The gallery disappears.
Member
Member
sbillard   2007-07-10, 23:55
#4
That means there is a syntax error on the line.

it should read
`for ($i=min(1,$current-5); $i < max($total, ($current+5)); $i++) {`
Member
Member
llapa   2007-07-11, 02:35
#5
Hi sbillard,
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
Member
Member
sbillard   2007-07-11, 14:06
#6
Sorry, I am dislexic so got the min/max wrong. Try this.

` for ($i=max(1, ($current-5)); $i <= min($total,($current+5)); $i++) {`
Member
Member
sbillard   2007-07-11, 17:28
#7
` for ($i=($j=max(1, $current-5)); $i <= min($total, $j+11); $i++) {`
would be even better.
Member
Member
llapa   2007-07-11, 20:58
#8
Hi sbillard,
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.
Member
Member
sbillard   2007-07-13, 00:21
#9
OK, I don't have enough albums to really try this but replace the code which reads:
` for ($i=($j=max(1, $current-5)); $i <= min($total, $j+11); $i++) {

echo "n <li" . (($i == $current) ? " class="current"" : "") . ">";

printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));

echo "</li>";

}`

with

` for ($i=($j=max(1, $current-2)); $i <= min($total, $j+5); $i++) {

echo "n <li" . (($i == $current) ? " class="current"" : "") . ">";

printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));

echo "</li>";

}

if ($i < ($total-2)) {echo "n [*]<a>" . ". . ." . "</a>"; }

for ($i=max($i+1, $total-2); $i <= $total; $i++) {

echo "n <li" . (($i == $current) ? " class="current"" : "") . ">";

printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));

echo "</li>";

}`

and let me know how it looks.
Member
Member
llapa   2007-07-13, 04:53
#10
The gallery disappears.
Member
Member
sbillard   2007-07-13, 15:52
#11
I see the problem. The WEB page swallowed some slashes. Everywhere it says echo "n it should be echo "\n

Here is the complete function:

`function printPageListWithNav($prevtext, $nexttext, $nextprev=true, $class="pagelist", $id=NULL) {

echo "";

$total = getTotalPages();

$current = getCurrentPage();

echo "\n<ul class="$class">";

if ($nextprev) {

echo "\n <li class="prev">";

printPrevPageLink($prevtext, "Previous Page");

echo "</li>";

}

for ($i=($j=max(1, $current-2)); $i <= min($total, $j+5); $i++) {

echo "\n <li" . (($i == $current) ? " class="current"" : "") . ">";

printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));

echo "</li>";

}

if ($i < ($total-2)) {echo "n [*]<a>" . ". . ." . "</a>"; }

for ($i=max($i+1, $total-2); $i <= $total; $i++) {

echo "\n <li" . (($i == $current) ? " class="current"" : "") . ">";

printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));

echo "</li>";

}

if ($nextprev) {

echo "\n <li class="next">";

printNextPageLink($nexttext, "Next Page");

echo "</li>";

}

echo "\n</ul>";

echo "\nn";

}`
and copy the code from the included files.
Member
Member
llapa   2007-07-13, 16:17
#12
It still disappears.
The original code I have there is:
`function printPageListWithNav($prevtext, $nexttext, $nextprev=true, $class="pagelist", $id=NULL) {

echo "";

$total = getTotalPages();

$current = getCurrentPage();

echo "\n<ul class=\"$class\">";

if ($nextprev) {

echo "\n <li class=\"prev\">";

printPrevPageLink($prevtext, "Previous Page");

echo "";

}

for ($i=1; $i <= $total; $i++) {

echo "\n <li" . (($i == $current) ? " class=\"current\"" : "") . ">";

printLink(getPageURL($i), $i, "Page $i" . (($i == $current) ? " (Current Page)" : ""));

echo "";

}

if ($nextprev) {

echo "\n <li class=\"next\">";

printNextPageLink($nexttext, "Next Page");

echo "";

}

echo "\n";

echo "\n\n";

}`
Member
Member
sbillard   2007-07-13, 16:18
#13
Probably still a transcription error. You can download effervescence_simpleviewer from the WIKI themes page http://www.zenphoto.org/trac/wiki/ZenphotoThemes and copy the code from the included file in version 2.1 of the theme.
Member
Member
llapa   2007-07-13, 16:48
#14
Now it works perfectly. You really are great. Thank you very much for your help. I sincerely appreciate it.
Member
Member
sbillard   2007-07-13, 23:33
#15
Glad to help, It was a good idea of yours.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.