Photo Gallery setup
30 posts by 7 authors in: Forums > CMS Builder
Last Post: April 30, 2012 (RSS)
By Chris - December 16, 2009 - edited: December 17, 2009
To make pages start at 1 instead of 0, replace this line:
$photoPage = @$_REQUEST['photoPage.php'];
with this:
$photoPage = @$_REQUEST['photoPage.php'] ? $_REQUEST['photoPage.php'] - 1 : 0;
Chris
Re: [chris] Photo Gallery setup
what i need to change to make it work strat from page 1 and add jump to page with out error.
this is my code:
<?php
$photosPerPage = 15;
$photoPage = @$_REQUEST['photoPage'];
$firstIndex = $photoPage * $photosPerPage;
$lastIndex = min($firstIndex + $photosPerPage, sizeof($clubsRecord['images'])) - 1;
foreach (range($firstIndex, $lastIndex) as $photoIndex):
$upload = $clubsRecord['images'][$photoIndex]
?>
<td align="center"><div class="pic"><a href="<?php echo $upload['urlPath'] ?>" rel="enlargeimage::click" rev="photoload"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt='' width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="middle" class="displayed" /></a></div></td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?>
</tr><tr>
<?php endif ?>
<?php endforeach; ?>
</tr></table>
<p><br/>
<?php if ($firstIndex > 0): ?>
<a href="?photoPage=<?php echo $photoPage-1; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/back.png" width="20" height="16" border="0" align="absmiddle" /></a>
<?php endif ?>
עמוד <?php echo($photoPage + 1); ?> מתוך <?php echo(ceil(sizeof($clubsRecord['images']) / $photosPerPage)); ?>
<?php if ($lastIndex < sizeof($clubsRecord['images']) - 1): ?>
<a href="?photoPage=<?php echo $photoPage+1; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/next.png" width="20" height="16" border="0" align="absmiddle" /></a><br />
<?php endif ?>
By Chris - December 17, 2009
You'll also need to replace this line:
<a href="?photoPage=<?php echo $photoPage-1; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/back.png" width="20" height="16" border="0" align="absmiddle" /></a>
with this:
<a href="?photoPage=<?php echo $photoPage; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/back.png" width="20" height="16" border="0" align="absmiddle" /></a>
And this line:
<a href="?photoPage=<?php echo $photoPage+1; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/next.png" width="20" height="16" border="0" align="absmiddle" /></a><br />
with this:
<a href="?photoPage=<?php echo $photoPage+2; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/next.png" width="20" height="16" border="0" align="absmiddle" /></a><br />
Chris
Re: [chris] Photo Gallery setup
now its start with page 2 and can't go to next or prev page...
you can paste the full code again?
By Chris - December 17, 2009
Try this?
<?php
$photosPerPage = 15;
$photoPage = @$_REQUEST['photoPage.php'] ? $_REQUEST['photoPage.php'] - 1 : 0;
$firstIndex = $photoPage * $photosPerPage;
$lastIndex = min($firstIndex + $photosPerPage, sizeof($clubsRecord['images'])) - 1;
foreach (range($firstIndex, $lastIndex) as $photoIndex):
$upload = $clubsRecord['images'][$photoIndex]
?>
<td align="center"><div class="pic"><a href="<?php echo $upload['urlPath'] ?>" rel="enlargeimage::click" rev="photoload"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt='' width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="middle" class="displayed" /></a></div></td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?>
</tr><tr>
<?php endif ?>
<?php endforeach; ?>
</tr></table>
<p><br/>
<?php if ($firstIndex > 0): ?>
<a href="?photoPage=<?php echo $photoPage; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/back.png" width="20" height="16" border="0" align="absmiddle" /></a>
<?php endif ?>
עמוד <?php echo($photoPage + 1); ?> מתוך <?php echo(ceil(sizeof($clubsRecord['images']) / $photosPerPage)); ?>
<?php if ($lastIndex < sizeof($clubsRecord['images']) - 1): ?>
<a href="?photoPage=<?php echo $photoPage+2; ?>&=<?php echo $clubsRecord['num'] ?>"><img src="images/next.png" width="20" height="16" border="0" align="absmiddle" /></a><br />
<?php endif ?>
Chris
Re: [chris] Photo Gallery setup
its problem when i add jump to page.
now its like page 1 is photoPage=0 and page 2 is photoPage=1..
i need it like this: page 1 is photoPage=1 and page 2 is photoPage=2 so when my user choose page 1 in the jump to page option thay get page number 1 and no number 2.
how can i add jump to page like this?
By Chris - December 17, 2009
The following works for me:
<?php
$photosPerPage = 2;
$photoPage = @$_REQUEST['photoPage'] ? $_REQUEST['photoPage'] - 1 : 0;
$firstIndex = $photoPage * $photosPerPage;
if ($firstIndex > sizeof($clubsRecord['images'])-1 || $firstIndex < 0) { $firstIndex = 0; $photoPage = 0; }
$lastIndex = min($firstIndex + $photosPerPage, sizeof($clubsRecord['images'])) - 1;
foreach (range($firstIndex, $lastIndex) as $photoIndex):
$upload = $clubsRecord['images'][$photoIndex]
?>
<td align="center"><div class="pic"><a href="<?php echo $upload['urlPath'] ?>" rel="enlargeimage::click" rev="photoload"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt='' width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" align="middle" class="displayed" /></a></div></td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?>
</tr><tr>
<?php endif ?>
<?php endforeach; ?>
</tr></table>
<p><br/>
<form action="?num=<?php echo $clubsRecord['num'] ?>" method="post">
<?php if ($firstIndex > 0): ?>
<a href="?photoPage=<?php echo $photoPage; ?>&=<?php echo $clubsRecord['num'] ?>"><< previous page</a>
<?php endif ?>
Page <input type="text" name="photoPage" value="<?php echo($photoPage + 1); ?>" style="width: 25px;" /><input type="submit" value="Go" /> of <?php echo(ceil(sizeof($clubsRecord['images']) / $photosPerPage)); ?>
<?php if ($lastIndex < sizeof($clubsRecord['images']) - 1): ?>
<a href="?photoPage=<?php echo $photoPage+2; ?>&=<?php echo $clubsRecord['num'] ?>">next page >></a><br />
<?php endif ?>
</form>
Does that work for you?
Chris
By ukash - April 30, 2012