Making images show up in Columns
2 posts by 2 authors in: Forums > CMS Builder
Last Post: December 2, 2010 (RSS)
I have a field called lamping_options. I have uploaded 4 images to this field. They show up one below the next. I have tried to use the same code as I did on the search page to have them displayed in columns. It does not work, since it treats all the images under lamping_options as one <td>
Here is the code:
<table width="700" align="center" cellpadding="2" cellspacing="2" border="5">
<tr> <?php foreach ($itemsRecords as $record): ?>
<td width="233" align="left">
<?php foreach ($itemsRecord['lamping_image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['urlPath'] ?>" rel="lightbox[dia]" alt="" title=""><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a><br/>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
<?php endif ?> <?php endforeach ?>
</td> <?php $maxCols=3; if (@++$count % $maxCols == 0): ?> </tr><?php endif ?> <?php endforeach ?> <tr> </table>
-------------------------------
How can I get each image to be displayed in another column? Is it possible? The reason I need them in one field is because I added a lightbox to them and It will not work if they are independent fields.
Thank You
Here is the code:
<table width="700" align="center" cellpadding="2" cellspacing="2" border="5">
<tr> <?php foreach ($itemsRecords as $record): ?>
<td width="233" align="left">
<?php foreach ($itemsRecord['lamping_image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['urlPath'] ?>" rel="lightbox[dia]" alt="" title=""><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a><br/>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
<?php endif ?> <?php endforeach ?>
</td> <?php $maxCols=3; if (@++$count % $maxCols == 0): ?> </tr><?php endif ?> <?php endforeach ?> <tr> </table>
-------------------------------
How can I get each image to be displayed in another column? Is it possible? The reason I need them in one field is because I added a lightbox to them and It will not work if they are independent fields.
Thank You
Re: [dccreatives] Making images show up in Columns
By Jason - December 2, 2010
Hi,
You're quite close. Since $itemsRecord is only 1 record, we don't need a foreach loop for it, so that can be removed. We just need to re-arrange the other code to fit inside our 1 foreach loop that we use for outputting the images.
Try this:
Hope this helps
You're quite close. Since $itemsRecord is only 1 record, we don't need a foreach loop for it, so that can be removed. We just need to re-arrange the other code to fit inside our 1 foreach loop that we use for outputting the images.
Try this:
<table width="700" align="center" cellpadding="2" cellspacing="2" border="5">
<tr>
<?php $maxCols=3;?>
<?php foreach ($itemsRecord['lamping_image'] as $upload): ?>
<td width="233" align="left">
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['urlPath'] ?>" rel="lightbox[dia]" alt="" title=""><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a><br/>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
<?php endif ?>
</td>
<? if (@++$count % $maxCols == 0): ?></tr><tr><?php endif ?>
<?php endforeach ?>
</tr>
</table>
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/