Multi column - again!

14 posts by 4 authors in: Forums > CMS Builder
Last Post: December 15, 2010   (RSS)

Re: [terryally] Multi column - again!

By Jason - December 14, 2010

Hi Terry,

The problem with using $maxCols=2 is that it will be triggered every other record. What you actually want to do is trigger this change once, at the half way point. Try something like this:

<?php $half = intval(count($public_inputsRecords)/2);?>
<?php foreach ($public_inputsRecords as $record): ?>
<div class="col1">
<div class="top"></div>
<div class="inner">
<div class="inner_text">
<span class="date">Posted: <?php echo date("D, M j Y", strtotime($record['createdDate'])) ?></span><br />
<?php echo $record['request'] ?><br />
<div class="name">- <?php echo $record['screen_name'] ?>, <?php echo $record['country'] ?></div>
</div>
</div>
<div class="end"></div></div>
<?php if (@++$count == $half): ?></div><div class="col2"><?php endif ?>
<?php endforeach ?>
</div>


This should be more what you're looking for.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

By terryally - December 14, 2010 - edited: December 14, 2010

Hi Jason,

Below is the slight change to the variable to put the divisor outside of the bracket (typo).

<?php $half = intval(count($public_inputsRecords))/2;?>

This however just parsed everything into a single column because the number of records was an odd number hence $half = x.5 records.

I added a second line variable to round the number:


<?php $half = round($half);?>

This then splits the records at the halfway point but but in the same way that I reported it in my previous email i.e.

</div><div class="col2"> <div class="col1">

</div><div class="col1">

</div> (etc etc etc)



So what the endif is doing after class col2 is terminating it and reintroducing class col1.

Any further thoughts

Terry
P.S. Apology for calling you Chris in prev msg. I edited it.

Re: [terryally] Multi column - again!

By Jason - December 15, 2010

Hi Terry,

Could you attach the entire .php file you're working with so I can take a look at the code? Also, if you have a url to the page so I can see the output that would help as well.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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