A Way to Feature the First Listing

2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 12, 2009   (RSS)

Re: [jdancisin] A Way to Feature the First Listing

By Damon - June 12, 2009

Hi,

Try adding a counter and then setting the results based on the counter number.

The counter starts at 1. Using an IF statement, you check if the counter equals 1 and if it does, output the code with the div tags.
If the counter doesn't equal 1, then it outputs the other code without the div tag.

<?php $counter = 1 ?>
<?php foreach ($listingRecords as $record): ?>
<?php if($counter == 1) : ?>
<div class="ClassNameHere">
<h3><?php echo $record['title'] ?></h3>
<h4><?php echo $record['year'] ?></h4>
<?php echo $record['introduction'] ?>
</div>
<?php else : ?>
<h3><?php echo $record['title'] ?></h3>
<h4><?php echo $record['year'] ?></h4>
<?php echo $record['introduction'] ?>
<?php endif; ?>
<?php $counter++ ?>
<?php endforeach; ?>


Hope this helps.
Cheers,
Damon Edis - interactivetools.com

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