LIMITING THE AMOUNT OF COLUMNS IN A MULTI ROW IMAGE DISPLAY - Feb 9th, 2013


The table example above is fine for a single row of images or information that you want to wrap every x columns. If you
want to set up sets of rows that you want to wrap, you’ll have to wrap your table inside a table. Here’s a 2 row
example using the thumbnail2 image as a link to a detail page, separate Title and Subtitle fields, a hidden border for
IE and a fixed height for the image cell so that everything lines up nicely.



<table width="100%" border="0" cellpadding="5">
<tr>
<td align="center" >
<tr>
<?php foreach ($your_sectionRecords as $record): ?><?php foreach ($record['image'] as $upload): ?>
<td align="center" width="50%">
<table>
<tr>
<td height="350" valign="bottom"><a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath2']
?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt=""
style="border:hidden" /></a>
</td>
</tr>
<tr>
<td ><div align="center" class="medium-title"><?php echo $record['title'] ?></div>
<div align="center" class="medium-text"><?php echo $record['sub_title'] ?></div></td></tr></table>
</td>
<?php $maxCols=2; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
<?php endforeach ?> <?php endforeach ?>
</tr>
</table>



Again, Use your own variable names instead of $your_sectionRecord, but the inserted code can stay the same.

*** If you’re going to use that little code snippet multiple times on the same page, just use a different variable
instead of $count or it will remember the count from the last section and increment that.

Instead of this:



<?php $maxCols=5; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>



Use these:



<?php $maxCols=5; if (@++$count1 % $maxCols == 0): ?></tr><tr><?php endif; ?>

<?php $maxCols=5; if (@++$count2 % $maxCols == 0): ?></tr><tr><?php endif; ?>

<?php $maxCols=5; if (@++$count3 % $maxCols == 0): ?></tr><tr><?php endif; ?>




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service