Photo Gallery setup

30 posts by 7 authors in: Forums > CMS Builder
Last Post: April 30, 2012   (RSS)

Re: [pchell] Photo Gallery setup

By Damon - October 17, 2009

Hi,

It looks like the code you submitted has a combination of detail page and list page code. Try this for your detail page:

Change the "require_once" path to match your server.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "your/path/to/cmsAdmin/lib/viewer_functions.php";

list($galleryRecords, $multi_galleryMetaData) = getRecords(array(
'tableName' => 'multi_gallery',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$galleryRecord = @$galleryRecords[0]; // get first record

// show error message if no matching record is found
if (!$galleryRecord) {
print "Record not found!";
exit;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
</head>
<body>

<h1><?php echo $galleryRecord['title'] ?></h1>

<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<?php foreach ($galleryRecord['photos'] as $upload): ?>
<td><a href="<?php echo $upload['urlPath'] ?>" title="<?php echo $record['title'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a></td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?>
</tr><tr>
<?php endif ?>
<?php endforeach; ?>
</tr></table><br/>

<?php if (!$galleryRecord): ?>
No images found!<br/><br/>
<?php endif ?>

</body>
</html>


To set a maximum number of images for each gallery:
- login in to CMS Builder
- go to Admin > Section Editor then select "modify" for Gallery
- click modify for photos
- in the popup, in the "Input Validation" area, you can set the "Maximum uploads". Check the box, enter 15 and save.

I hope this helps. If you have any questions, just let me know.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Photo Gallery setup

By Codee - October 17, 2009

PC Hell,

Looks like the answer to your question about limiting the number of photos on the details page wasn't answered the way you intended, was it? The answer from Damon had to do with how many photos/pics can be uploaded for each record (for that field) and not for how many from that record to show. When I read your post I thought you meant you were trying to limit the number of viewable pics from a record on a single detail page, and have a next page created for the rest of the pics from the same record. Is that correct?

In other words...say you allow 99 pics per record in your gallery...but you only want to show 15 on the first detail page and have CMSB automatically create additional or addended detail page, as needed, until the total number for that record is displayed. Is this what you're asking?

Re: [equinox69] Photo Gallery setup

By (Deleted User) - October 17, 2009

Yes, this is what I would like...

[font "Verdana"]"say you allow 99 pics per record in your gallery...but you only want to show 15 on the first detail page and have CMSB automatically create additional or addended detail page, as needed, until the total number for that record is displayed."

How can I accomplish this?

Re: [pchell] Photo Gallery setup

By Chris - October 19, 2009

Hi pchell,

That's a little tricky. How about something like this?

<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<?php
$photosPerPage = 6;
$photoPage = @$_REQUEST['photoPage'];
$firstIndex = $photoPage * $photosPerPage;
$lastIndex = min($firstIndex + $photosPerPage, sizeof($galleryRecord['photos'])) - 1;
foreach (range($firstIndex, $lastIndex) as $photoIndex):
$upload = $galleryRecord['photos'][$photoIndex]
?>
<td><a href="<?php echo $upload['urlPath'] ?>" title="<?php echo $record['title'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a></td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?>
</tr><tr>
<?php endif ?>
<?php endforeach; ?>
</tr></table><br/>

<?php if ($firstIndex > 0): ?>
<a href="?photoPage=<?php echo $photoPage-1; ?>&num=<?php echo $galleryRecord['num'] ?>">previous photos</a><br />
<?php endif ?>

<?php if ($lastIndex < sizeof($galleryRecord['photos']) - 1): ?>
<a href="?photoPage=<?php echo $photoPage+1; ?>&num=<?php echo $galleryRecord['num'] ?>">next photos</a><br />
<?php endif ?>


I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Photo Gallery setup

By (Deleted User) - October 19, 2009

Thanks Chris,

That worked out perfectly, except I changed title="<?php echo $record['title'] ?>"> to $upload['info1'] and it worked by showing the title of the picture.

Exactly what I wanted.

Re: [pchell] Photo Gallery setup

By efi-revivo - November 16, 2009

1. I use this code for my photo gallery and when i try to go to the next page its not working...

<table width="100%" border="0" cellspacing="3" cellpadding="3">
<tr>
<?php
$photosPerPage = 15;
$photoPage = @$_REQUEST['photoPage.php'];
$firstIndex = $photoPage * $photosPerPage;
$lastIndex = min($firstIndex + $photosPerPage, sizeof($weekpicRecord['images'])) - 1;
foreach (range($firstIndex, $lastIndex) as $photoIndex):
$upload = $weekpicRecord['images'][$photoIndex]
?>
<td><a href="<?php echo $upload['urlPath'] ?>" rel="enlargeimage::click" rev="loadarea"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="75" height="75" alt="" /></a></td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?>
</tr><tr>
<?php endif ?>
<?php endforeach; ?>
</tr></table><br/>

<?php if ($firstIndex > 0): ?>
<a href="?photoPage.php=<?php echo $photoPage-1; ?>&num=<?php echo $weekpicRecord['num'] ?>">previous photos</a><br />
<?php endif ?>

<?php if ($lastIndex < sizeof($weekpicRecord['images']) - 1): ?>
<a href="?photoPage.php=<?php echo $photoPage+1; ?>&num=<?php echo $weekpicRecord['num'] ?>">next photos</a><br />
<?php endif ?>

2. how can i show the number of pages like: 1 of 3 next pages | previous pages

Re: [efi-revivo] Photo Gallery setup

By Chris - November 18, 2009 - edited: November 18, 2009

Hi efi-revivo,

Do you have an example online so I can see how it's not working? If not, can you please explain exactly what's going wrong?

> 2. how can i show the number of pages like: 1 of 3 next pages | previous pages

How about this after the </table><br />:

<?php echo($photoPage + 1); ?> of <?php echo(ceil(sizeof($weekpicRecord['images']) / $photosPerPage)); ?>

I hope this helps!
All the best,
Chris

Re: [chris] Photo Gallery setup

By efi-revivo - November 18, 2009

yes http://www.midnights.co.il/girlstar.php?Liat-1

and i need to show the number of pages not the number of images...

Re: [efi-revivo] Photo Gallery setup

By Chris - November 18, 2009

Hi efi-revivo,

Oops, I must have been half-asleep when I posted that. I've updated the code above to display the total number of pages instead of the total number of images.

It seems like your page isn't setting $photoPage from the query string. I would try changing "photoPage.php" back to "photoPage". If that doesn't fix things, please post the complete PHP source code of your page as an attachment and I'll have a look.
All the best,
Chris