How to split listing records

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

Re: [rebjr] How to split listing records

By ross - April 16, 2009

Hi there

Thanks for posting!

Do both your <div> blocks need to be right next to one another in the code (not nessesarily displayed next to one another). Or would they be in different places of the code?

Also, do you have a sample mockup of the page so I can have a look at it?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [rebjr] How to split listing records

By Dave - April 16, 2009

Hi rebjr,

Try adding a counter and testing that instead. Something like this:

foreach ($practice_areasRecords as $record):
@$counter++;
if ($counter <= $desired_num ) { ...


You'll want to update that in both places to use $counter instead of $record['num'].

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] How to split listing records

By rebjr - April 16, 2009

I ended up solving it this way, using dragSortOrder as an index into the array:

<div class="span-3 append-1">
<ul>
<?php
$desired_num = $firsthalf; // Show the first half of the records
foreach ($practice_areasRecords as $record):
if ($record['dragSortOrder'] >= $desired_num ) {

?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php
}
endforeach;
?>
<?php if (!$practice_areasRecords): ?>
<li>No records were found!</li>
<?php endif ?>
</ul>
</div> <!-- // .span-3 append-1 -->

<div class="span-3">
<ul>
<?php
$desired_num = $firsthalf; // Use to show the rest of the records
foreach ($practice_areasRecords as $record):
if ($record['dragSortOrder'] < $desired_num ) {

?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php
}
endforeach;
?>
</ul>
</div> <!-- // .span-3 -->