columns in a multi row image display in a single row list viewer

3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 25, 2015   (RSS)

By 4cdg - August 21, 2015

Trying to have a multi column rows of images inside a single row list viewer, having trouble with the underlined part of the code below.

Because this is nested inside of the list viewer, i am not sure how to change my count name per record, so this count starts over for each record.

You can see what it is doing here, first record has 4 photos, second has 1, third has 2, then on the forth it has 2, but the counter thinks the first image is #4 and second goes to next row.....

<table>
<?php foreach ($capabilities_services_multiRecords as $record): ?>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td class="tahoma-red"><strong><?php echo htmlencode($record['title']) ?></strong></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="30%" valign="top"><?php $record['content'] = preg_replace("/^\s*<p>/i", "", $record['content'] ); ?><?php $record['content'] = preg_replace("|</p>\s*$|i", "", $record['content'] ); ?><?php echo $record['content']; ?>&nbsp;</td>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="4">
                  <tr><?php foreach ($record['photos'] as $index => $upload): ?>
                    <td width="25%" align="center"><table border="0" align="center" cellpadding="1" cellspacing="0" class="tahoma_12">
  <tr>
    <td align="center"><a href="<?php echo htmlencode($upload['urlPath']) ?>" class="highslide" onclick="return hs.expand(this)"><img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a><div class="highslide-heading">
 <?php echo htmlencode($upload['info1']) ?>
    <br /><?php echo htmlencode($upload['info2']) ?>
</div></td>
  </tr>
  <tr>
    <td align="center">
<?php echo htmlencode($upload['info1']) ?>
    <br /><?php echo htmlencode($upload['info2']) ?>
</td>
  </tr>
</table>
</td>
                  <?php $maxCols=4; if (@++$count % $maxCols == 0): ?>
              </tr>
              <?php endif; ?>
              <?php endforeach ?>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><hr /></td>
          </tr>
        </table></td>
      </tr>
      <?php endforeach ?>
</table>

By Damon - August 25, 2015

Hi,

It looks like you just need to reset the counter after each record of images. You can do can that with this:
<?php $count = 0; //reset counter ?>

I added it to the code below in bold.

<table>
  <?php foreach ($capabilities_services_multiRecords as $record): ?>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td class="tahoma-red"><strong><?php echo htmlencode($record['title']) ?></strong></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="30%" valign="top"><?php $record['content'] = preg_replace("/^\s*<p>/i", "", $record['content'] ); ?>
                  <?php $record['content'] = preg_replace("|</p>\s*$|i", "", $record['content'] ); ?>
                  <?php echo $record['content']; ?>&nbsp;</td>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="4">
                    <tr>
                    
                      <?php foreach ($record['photos'] as $index => $upload): ?>
                      <td width="25%" align="center"><table border="0" align="center" cellpadding="1" cellspacing="0" class="tahoma_12">
                          <tr>
                            <td align="center"><a href="<?php echo htmlencode($upload['urlPath']) ?>" class="highslide" onClick="return hs.expand(this)"><img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a>
                              <div class="highslide-heading"> <?php echo htmlencode($upload['info1']) ?> <br />
                                <?php echo htmlencode($upload['info2']) ?> </div></td>
                          </tr>
                          <tr>
                            <td align="center"><?php echo htmlencode($upload['info1']) ?> <br />
                              <?php echo htmlencode($upload['info2']) ?></td>
                          </tr>
                        </table></td>
                      <?php $maxCols=4; if (@++$count % $maxCols == 0): ?>
                    </tr>
                    <?php endif; ?>
                    <?php endforeach ?>
                    <?php $count = 0; //reset counter ?>
                  </table></td>
              </tr>
            </table></td>
        </tr>
        <tr>
          <td><hr /></td>
        </tr>
      </table></td>
  </tr>
  <?php endforeach ?>
</table>

And if this doesn't work, can you send in a support request with link to the actual page and login/FTP details:
https://www.interactivetools.com/support/email_support_form.php
Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/