I'm trying to build a calendar that I can populate with CMS Builder records. The calendar would then list records in it's date table cells in relation to the records' correspond date and time set for the record within CMS Builder.
Each event would list the event's "title, date and time, description, location, content and a link to the eventDetails.php event page.
I've got the calendar part built, but I can't figure out how to get the CMS Builder records into the corresponding calendar dates, so the calendar is populated with content, based on the record's date and time I set within CMS Build.
See my comment note in the code for the info I'm trying to push into the calendar. (<!-- this needs to go into the calendar and the event be placed on the corresponding date the record is related with -->)
I've provided the code I've built so far below, along with the css. Anyone have any suggestions on how to get CMS Builder to populate this calendar with content?
Thanks, Zick
========== CSS ============
@charset "UTF-8";
body {
margin:0 auto;
background: #fff;
}
.CalNextPrevious {
font-family: "Trebuchet MS", "Trebuchet MS Bold";
font-weight: bold;
font-size: 12px;
color:#FFFFFF;
background-color:#333;
}
.CalMonth {
font-family: "Trebuchet MS", "Trebuchet MS Bold";
font-weight: bold;
font-size: 18px;
color:#FFFFFF;
background-color:#999;
padding-top:8px;
padding-bottom:4px;
}
.CalDayofWeek {
font-family: "Trebuchet MS", "Trebuchet MS Bold";
font-weight: bold;
font-size: 14px;
color:#000;
background-color:#CCC;
text-align:center;
padding-top:8px;
padding:6px;
}
.CalDates {
font-family: "Trebuchet MS", "Trebuchet MS Bold";
font-weight:normal;
font-size: 14px;
color:#000000;
text-align:left;
background-color:#EAEAEA;
margin:0px;
padding:6px;
border-top:#FFF solid 1px;
border-left:#FFF solid 1px;
border-right:#FFF solid 1px;
border-bottom:#FFF solid 1px;
}
#calFonts {
width:102px;
}
#calFonts h1 {
font-family: "Trebuchet MS", "Trebuchet MS Bold";
font-weight: bold;
font-size: 13px;
color:#333;
}
#calFonts h3 {
font-family: "Trebuchet MS", "Trebuchet MS Bold";
font-weight: bold;
font-size: 12px;
color:#333;
}
#calFonts p {
font-family: "Trebuchet MS", "Trebuchet MS Bold";
font-weight: bold;
font-size: 10px;
color:#333;
}
========== /CSS ============
========== CALENDAR CODE ============
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
require_once "/var/www/thishosts/thisdomain.com/httpdocs/cmsbuilder/lib/viewer_functions.php";
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
'perPage' => '32',
));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="css/calendar1.css" type="text/css" />
</head>
<body>
<div id="container">
<!-- calendar -->
<?php
$monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];
$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>
<div id="calendar_div" name="calendar_div">
<table border="0" cellpadding="1" cellspacing="0" bgcolor="#333333">
<tr align="center">
<td bgcolor="#333333"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="left"> <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" class="CalNextPrevious">Previous</a></td>
<td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" class="CalNextPrevious">Next</a> </td>
</tr>
</table></td>
</tr>
<tr>
<td align="center"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr align="center">
<td colspan="7" class="CalMonth" ><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></td>
</tr>
<tr>
<td class="CalDayofWeek">Sunday</td>
<td class="CalDayofWeek">Monday</td>
<td class="CalDayofWeek">Tuesday</td>
<td class="CalDayofWeek">Wednesday</td>
<td class="CalDayofWeek">Thursday</td>
<td class="CalDayofWeek">Friday</td>
<td class="CalDayofWeek">Saturday</td>
</tr>
<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 0 ) echo "<tr>\n";
if($i < $startday) echo "<td></td>\n";
else echo "<td class='CalDates'>". ($i - $startday + 1) . "</td>\n";
if(($i % 7) == 6 ) echo "</tr>\n";
}
?>
</table></td>
</tr>
</table>
<br />
<!-- /calendar --></div>
<!-- /container --></div>
<br />
<div id="calFonts"><!-- this needs to go into the calendar and the event be placed on the corresponding date the record is related with -->
<?php foreach ($eventsRecords as $record): ?>
<h3>Title: <?php echo $record['title'] ?></h3>
<h3>Date and Time: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date_and_time'])) ?></h3>
<p>Description: <?php echo $record['description'] ?></p>
<p>Location: <?php echo $record['location'] ?></p>
<p>Content: <?php echo $record['content'] ?></p>
<p>Event Details: <a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></p>
<?php endforeach ?>
<!-- /this needs to go into the calendar and the event be placed on the corresponding date the record is related with --></div>
</body>
</html>
========== /CALENDAR CODE ============