3 column display

7 posts by 2 authors in: Forums > CMS Builder
Last Post: June 23, 2014   (RSS)

By claire - June 19, 2014

Hi there

I don't think there's an issue with your code. Are you resetting the $count variable after every header?

--------------------

Claire Ryan
interactivetools.com

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

By degreesnorth - June 19, 2014

Hi Claire

What does that mean - resetting the $count variable?  Where/what should that look like?

Thanks

By claire - June 20, 2014

The $count variable is a counter that basically ticks up every time a column is added. It's used to determine how many columns there should be in each row. Here's how the code works:

<table width="618" border="0">
  <tr>
    <h1><?php echo $gold_sponsors_titleRecord['title']; ?></h1>      
    <?php if ($gold_sponsors_titleRecord['intro']): ?><p style="line-height: 120%"><font face="Arial" style="font-size: 12px"><?php echo htmlencode($gold_sponsors_titleRecord['intro']) ?></font></p><?php endif; ?>

This starts a new set of columns and adds the title (Gold Sponsors, Partners, etc).

<?php foreach ($gold_sponsorsRecords as $record): ?>

This starts the loop that adds all the columns with the logos in them.

<td><a target="_blank" href="<?php echo $record['_link'] ?>"><img border="0" src="http://www.meetingonthegreen.com.au/cmsAdmin/uploads/<?php echo htmlencode($record['logo_name']) ?>" width="170"></a></td>            

This adds the columns themselves.

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

This bit is the important part. Basically what it does is make the counter tick up by one, and then it checks to see if the counter number is exactly divisible by 3. If so, it starts a new row of columns.

<?php endforeach ?> </tr>  </table>
</td>
</tr>

This ends the loop and closes the set.

So what should happen is that the counter should be set back to zero every time it starts a new section. If it's not being reset properly, then you get odd behaviour like you're seeing right now.

Best thing to do is show me the entire code for that page. If you're looking for it, it should be something like

$count = 0;

--------------------

Claire Ryan
interactivetools.com

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

By degreesnorth - June 22, 2014

Hi Claire

Thanks for this, but that's what I have (or not sure if your last line of code was meant to contain something other than $count = 0;  ?  I have attached the file to see whether you can shed any more info on this. 

By claire - June 23, 2014

No, I just thought I should explain how it works so that the solution will make sense (hopefully!)

Add this line after each of your headers, like so:

<h1><?php echo $diamond_sponsor_titleRecord['title']; ?></h1>
<?php $count = 0; ?>

Do the same for platinum, gold, silver, etc. This should reset the column counter every time you start a new section. It might need to be set to 1 instead of 0 but it's most likely that this will work.

Let me know if that does it.

--------------------

Claire Ryan
interactivetools.com

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

By degreesnorth - June 23, 2014

Thanks, that fixed it.