Events grouping?

5 posts by 3 authors in: Forums > CMS Builder
Last Post: June 20, 2009   (RSS)

Re: [Toledoh] Events grouping?

By ross - June 19, 2009

Hi Tim

Thanks for posting!

There are a few options for you here. The easier ones would basically show you everything within a week from today. So if today was Wednesday, it would show you Wednesday to Wednesday. If you wanted to only show the current week regardless of what day it is (even if it's Thursday, you still see, Monday to Friday), it gets quite a bit more complicated.

Let me know if a single week from today onwards will work.

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: [ross] Events grouping?

By Toledoh - June 19, 2009

A single week would be fine Ross - thanks.

Any ideas on how to group the results so it displays;

Tues: 25 Jan
- Event 1
- Event 2
Wednesday: 26 Jan
- Event

etc. Rather than;

Tues: 25 Jan: Event 1
Tues: 25 Jan: Event 2
Wed: 36 Jane: Event 3...

Cheers,
Tim
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Events grouping?

By Damon - June 20, 2009

Hi,

Here is some code to get the events to group under each date:

<?php $lastDate = ""; ?>
<?php foreach($newsRecords as $record):
$showDate = false;
$formatted_date = date("D, M jS, Y", strtotime($record['date']));
if ($formatted_date != $lastDate) :
$lastDate = $formatted_date;
$showDate = true;
endif;
?>
<?php if ($showDate): ?>
<strong><?php echo $formatted_date; ?></strong><br />
<?php endif ?>
Title: <?php echo $record['title'] ?><br/>
Summary: <?php echo $record['summary'] ?><br/>
<a href="<?php echo $record['_link'] ?>">Read More</a><br/><br />
<?php endforeach ?>


Just change the variable names to match yours as needed.

For the other part, showing events starting today and for the next seven days, I'm thinkning probably use php to get todays date then copy that to anther variable and add 7 days to the date. Next you would pass it as a date ange query into the WHERE statement. Gets a little tricky but doable. Ross may have had another idea about doing this so I will ask him on Monday.

Give this all a go and let us know how you make out.
Cheers,
Damon Edis - interactivetools.com

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

Re: [Damon] Events grouping?

By Toledoh - June 20, 2009

You guys make everything so easy... I've been struggling with this for days... Thanks!
Cheers,

Tim (toledoh.com.au)