Events grouping?

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

By Toledoh - June 19, 2009 - edited: June 19, 2009

Hi Guys,

Can anyone suggest a good way of displaying a calendar of events?

My client has a large number of events.... about 6 per week. I guess I'd like to group them together in date format (this is how they are entered) but it get's quiet cluttered.

I was thinking there may be a way of grouping them into days, then listing for a weeks view, or next 10 days, or a months view etc.

ie.

This week:
- Monday
:: Event 1
:: Event 2
- Tuesday
:: Event 3
- Wednesday
- Thursday
:: Event 4
:: Event 5
:: Event 6
- ......

Any suggestions?

Cheers,
Cheers,

Tim (toledoh.com.au)

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: [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)