Laying out tables to force data

4 posts by 3 authors in: Forums > CMS Builder
Last Post: January 23, 2009   (RSS)

By misery217 - January 22, 2009

I did this once upon a time in days of yore and probably with Article Manager, but as a N00b to CMS Builder, here is the question:

Say I want to have a photo gallery in a table with 3 columns across and I want the data to go across and up and down. I've put the code in the first cell of one table with 3 columns, however all this accomplishes is to have it post to the far left with the next image below it (Of which I want to appear to its right and so on). I've probably forgotten, but what is the magic trick to accomplish this? I indeed did search through the forum to no avail.

Thank for all the help!


Re: [misery217] Laying out tables to force data

By Dave - January 22, 2009

Hi Aaron, Welcome to the CMS Builder forum! :)

If I'm understand correctly there's a couple ways to do that. The CSS way is to have each image in a div that has something like: style="float: left; width: 200px". This will make them flow from left to right and wrap when they run out of space (you can put them inside a bigger fixed width container).

Or with a table you can have one tablecell per image and insert a closing and opening TR every X images. Here's a code snippet that does that:

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

Which is just a way of saying "Every 3 images insert "</tr><tr>"". So you'd have something like this:

<?php foreach ($record['uploads'] as $upload): ?>
<td> ... show upload ... </td>

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

<?php endforeach ?>

Hope that makes sense. Let me know if you have any other questions.
Dave Edis - Senior Developer

Re: [Dave] Laying out tables to force data

By misery217 - January 23, 2009

Wow, okay, the table code was EXACTLY what I was needing!!! Thanks so much Dave!! No on to more questions!