Photo Gallery setup

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

By (Deleted User) - October 17, 2009

Hi,

Ok, I've searched the forums and cant find exactly what I need. I have a gallery section where I have multiple galleries. I need to create a page with 3 columns of images wide and 5 columns deep (15 images per page). Because of my gallery setup, I guess I need to use the gallerydetails code viewer to do this, but I dont find an option to define how many photos on a detail viewer page and I have used the following code to create the page.

However, I also want to add the Gallery Title to the title of the html page and as a H1 tag in the page, but I keep getting an
Undefined variable: record" error showing up. The name of the gallery title is title, but I cant make it work.

Any help is appreciated!

Mark

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1><?php echo $record['title'] ?> Photo Gallery</h1>


<table width="100%" border="0" cellspacing="3" cellpadding="3"><tr>
<?php foreach ($galleryRecords as $record): ?>
<?php foreach ($record['photos'] as $upload): ?>
<td><a href="<?php echo $upload['urlPath'] ?>" rel="lightbox"
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 ?>
<?php endforeach; ?>
</tr></table><br/>


<hr/>
<?php if (!$galleryRecord): ?>
No record found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

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