creating duplicate records for a date range

9 posts by 2 authors in: Forums > CMS Builder
Last Post: September 16, 2010   (RSS)

By Deborah - December 9, 2009

I have a calendar that displays CMSB records from an xml.php file. Each event is displayed on the calendar based on what is entered with a date field.

For events that occur weekly, this would mean that one would need to create 52 records for a year's worth of this event. Using two date fields (start date + stop date), and making only one entry, would it be possible with PHP to have the same information for a record print for each date within the start and stop range?

Hope that makes sense.

Deborah

Re: [Deborah] creating duplicate records for a date range

By Chris - December 10, 2009

Hi Deborah,

That's a very custom configuration you've got there. I'm afraid we can't provide free support for this.

It would be possible to set something up so you can have "repeating events", but we'd have to help you through our consulting service. Please let me know if you're interested in this.
All the best,
Chris

Re: [chris] creating duplicate records for a date range

By Deborah - December 10, 2009

Thanks for the reply, Chris.

Unfortunately, this is a non-profit community project for which I can't request additional funds. Good to know that it is possible to create repeating events for a calendar. I'll probably run into that situation for a regular project in the future and can hire your services.

Deborah

Re: [Deborah] creating duplicate records for a date range

By Chris - January 25, 2010

Hi Deborah,

I've been thinking about calendars and schedules recently, and, on second reading, your request doesn't seem so complicated. If you'd still like help with it, please post your xml.php code. :)
All the best,
Chris

Re: [chris] creating duplicate records for a date range

By Deborah - January 26, 2010

Hi, Chris.

Thanks for your kind offer. Here is the xml.php code:

<?php header('Content-type: application/xml; charset=utf-8'); ?>
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<?php require_once "/var/www/vhost/80/p/www.peabody.lib.me.us/cmspeabody/lib/viewer_functions.php";
list($calendarRecords, $calendarMetaData) = getRecords(array(
'tableName' => 'calendar',
));
?>
<calendar>
<?php foreach ($calendarRecords as $record): ?>
<event>
<date><?php echo date("Y-m-d", strtotime($record['date'])) ?></date>
<title><?php echo htmlspecialchars ($record['title']) ?></title>
<url><?php echo $record['_link'] ?></url>
</event>
<?php endforeach; ?>
</calendar>


As an example, this client wanted to be able to enter a standard Saturday event for multiple blocks of Saturdays (such as 3 months).

I look forward to anything you come up with. And if you need a beta tester, I'm happy to help out.

Deborah

Re: [chris] creating duplicate records for a date range

By Deborah - January 26, 2010

Hi, Chris.

I understand the concept, but will need a few days to work with the code you supplied, because I'm on deadline with something right now.

All of my sites run PHP 5+ which would allow for the "easier option", but I understand if this is to become a built-in feature in CMSB, it may need to be available for older PHP versions.

Thanks and I'll get back to you to let you know how it worked out.
Deborah

Re: [Deborah] creating duplicate records for a date range

By Deborah - September 16, 2010

Chris and Forum Go-ers,

Sorry for the nine-month delay in replying to Chris' post. The client I wanted to accomplish this for entered the events manually before I had a chance to test this out.... then I got busy.

Today I tested out Chris' solution and it worked perfectly for me. Thought others here might want to know.

Chris, a very belated "Thank You"!

~ Deborah

Re: [Deborah] creating duplicate records for a date range

By Chris - September 16, 2010

Hi Deborah,

Glad that worked out for you! :)
All the best,
Chris