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

Hi efi-revivo,

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;
All the best,
Chris

Re: [chris] Photo Gallery setup

Still not working..
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 ?>
&#1506;&#1502;&#1493;&#1491; <?php echo($photoPage + 1); ?> &#1502;&#1514;&#1493;&#1498; <?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 ?>

Re: [chris] Photo Gallery setup

sorry chris but still not working..
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

Hi efi-revivo,

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 ?>
&#1506;&#1502;&#1493;&#1491; <?php echo($photoPage + 1); ?> &#1502;&#1514;&#1493;&#1498; <?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 ?>

All the best,
Chris

Re: [chris] Photo Gallery setup

no.. still start at page 0 and no page 1
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

Hi efi-revivo,

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'] ?>">&lt;&lt; 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 &gt;&gt;</a><br />
<?php endif ?>
</form>


Does that work for you?
All the best,
Chris

Re: [chris] Photo Gallery setup

thanks :-)
now it works great.

By ukash - April 30, 2012

is it not work in my web site http://www.ukash-tr.com i use chrome is it run chrome version
thanks

Re: [ukash] Photo Gallery setup

By efi-revivo - April 30, 2012 - edited: April 30, 2012

yes