Upcoming Events Listings

2 posts by 2 authors in: Forums > CMS Builder
Last Post: May 31, 2010   (RSS)

Re: [paulmac] Upcoming Events Listings

By Jason - May 31, 2010

Hi,

First thing you need to do is when you select your records, to order them by their date:

<?php
list($eventRecords,$eventMetaData)=getRecords(array(
'tableName' => 'events',
'orderBy' => 'start_date'
));
?>


Next, use this code where you're outputting your records:
<?php $heading = ""; ?>
<?php foreach ($eventRecords as $event): ?>
<?php if($heading!=date("F Y",strtotime($event['start_date']))): ?>
<?php $heading=date("F Y",strtotime($event['start_date'])); ?>
<?php echo $heading; ?> <br />
<?php endif ?>
<?php echo date("d-m-Y",strtotime($event['start_date'])); ?> - <?php echo $event['title']; ?><br />
<?php endforeach ?>


For each record, it checks to see if the month and year have changed. If they have, they output the new heading. Of course, you'll need to change the names here to match what you have in your database.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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