Gallery Image: Display a single record item within a list viewer
4 posts by 2 authors in: Forums > CMS Builder
Last Post: December 28, 2008 (RSS)
By avrom - December 27, 2008
I saw you answered my two other posts and thank you for that - much appreciated ;)) Hope you had a great Christmas and welcome back ^^.
On a different project I am creating a list viewer to display gallery images. I have a multiple table record called "gallery". Within the gallery record are the uploads ;)) I have started the detail viewer gallery.php
In the following code I want to replace the middle section where all the images are displayed with the code that would actually display only the first thumbnail from that record:
Thanking you in advance...
Avrom
<?php foreach ($galleryRecords as $record): ?>
<!-- Display gallery -->
<div id="gallery">
<?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<img src="<?php echo $record['_link'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="<?php echo $record['gallery_title'] ?>" title="<?php echo $record['gallery_title'] ?>" />
<?php endif ?>
<?php endforeach ?>
<h1><a href="<?php echo $record['_link'] ?>"><?php echo $record['gallery_title'] ?></a></h1>
<p><?php echo $record['details'] ?></p>
</div>
<?php endforeach ?>
Re: [virgodesign] Gallery Image: Display a single record item within a list viewer
By Dave - December 27, 2008
Try replacing the foreach loop with something like this:
<?php foreach ($record['images'] as $upload): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>"
width="<?php echo $upload['thumbWidth'] ?>"
height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php break; ?>
<?php endforeach ?>
Since it's a gallery we can drop the if isImage or if hasThumbnail since we know there will always be images and they'll always have thumbnails. Next, we use the thumbnail variables (eg: thumbUrlPath, etc) to show the thumbnail instead of the full size image. Finally, we add a break on the end to "break out of the loop" after just one pass.
Hope that helps, let me know if that does what you need.
interactivetools.com
Re: [Dave] Gallery Image: Display a single record item within a list viewer
By avrom - December 27, 2008
Re: [virgodesign] Gallery Image: Display a single record item within a list viewer
By avrom - December 28, 2008
I also found this solution in an earlier posting while looking for something else, I think it works well too:
http://www.interactivetools.com/forum/gforum.cgi?post=67071#67071
<?php $upload = $record['images'][0]; ?>
rest of code...
Cheers
Avrom