Calendar populated with CMS Builder records

46 posts by 12 authors in: Forums > CMS Builder
Last Post: February 27, 2012   (RSS)

By Mikey - August 29, 2010

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">&nbsp;&nbsp;<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>&nbsp;&nbsp;</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 ============

Re: [zickey] Calendar populated with CMS Builder records

By Chris - August 30, 2010 - edited: August 31, 2010

Hi Zick,

There are two approaches you could take here:

1. Loop over every event in each day, skipping over elements which have a date which doesn't match the day.

2. Reorganize events into an array indexed by 'day', each element being a list of events on that day.

I've made some changes to your code with the second approach, which is a little more complicated but probably more sensible when dealing with lots of records.

Also, it makes sense to only return records from the database which are in the selected month. I've added a 'where' clause to getRecords() to do that. I had to move it below your $cMonth and $cYear code to do this.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "C:/wamp/www/sb/CMS Builder/cmsAdmin/lib/viewer_functions.php";

?>
<!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;
}

// get event records for the selected month
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
'where' => mysql_escapef('MONTH(date) = ? AND YEAR(date) = ?', $cMonth, $cYear),
));

// organize events into an array indexed by 'day', each element being a list of events on that day
$eventsByDay = array();
foreach ($eventsRecords as $event) {
$day = intval(date('d', strtotime($event['date'])));
if (!array_key_exists($day, $eventsByDay)) { $eventsByDay[$day] = array(); }
$eventsByDay[$day][] = $event;
}


?>
<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">&nbsp;&nbsp;<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>&nbsp;&nbsp;</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 {
$day = $i - $startday + 1;
echo "<td class='CalDates'>". $day . "<br />";
// check if there are any events for this day
if (array_key_exists($day, $eventsByDay)) {
// list all events for this day
foreach ($eventsByDay[$day] 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'])) ?></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
}
}
echo "</td>\n";
}

if(($i % 7) == 6 ) echo "</tr>\n";
}
?>

</table></td>
</tr>
</table>
<br />
<!-- /calendar --></div>
<!-- /container --></div>
</body>
</html>


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Calendar populated with CMS Builder records

By Mikey - August 31, 2010 - edited: August 31, 2010

Hey Chris this works great for calendar dates 10 through 31, however calendar dates 1 through 9 do not load. I tried to figure out how to get dates 1-9 to load, but had no luck. Can you shed some light on what I need to do now?

And thank's for the help with this... it's almost there and works perfectly for dates 10-31, all the information loads right and the link to the event details functions perfectly.

Zick

PS: I meant to mention that I tested this exactly as you had it built and only the dates 10-31 would show. So, I eliminated the (date_and_time) record altogether and change the code to reference the (date) record instead. So here's the code you worked on, with the (date_and_time) removed and changed to reference the (date) record instead.

========== code ===========

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "C:/wamp/www/sb/CMS Builder/cmsAdmin/lib/viewer_functions.php";

?>
<!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;
}

// get event records for the selected month
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
'where' => mysql_escapef('MONTH(date) = ? AND YEAR(date) = ?', $cMonth, $cYear),
));

// organize events into an array indexed by 'day', each element being a list of events on that day
$eventsByDay = array();
foreach ($eventsRecords as $event) {
$day = date('d', strtotime($event['date']));
if (!array_key_exists($day, $eventsByDay)) { $eventsByDay[$day] = array(); }
$eventsByDay[$day][] = $event;
}

?>
<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">&nbsp;&nbsp;<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>&nbsp;&nbsp;</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 {
$day = $i - $startday + 1;
echo "<td class='CalDates'>". $day . "<br />";
// check if there are any events for this day
if (array_key_exists($day, $eventsByDay)) {
// list all events for this day
foreach ($eventsByDay[$day] as $record) {
?>
<h3><?php echo $record['title'] ?></h3>
<h3>Time: <?php echo date("g:i:s a", strtotime($record['date'])) ?></h3>
<p>Description: <?php echo $record['description'] ?></p>
<p>Location: <?php echo $record['location'] ?></p>
<!-- <p>Content: <?php echo $record['content'] ?></p>-->
<p>Details: <a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></p>
<?php
}
}
echo "</td>\n";
}
if(($i % 7) == 6 ) echo "</tr>\n";
}
?>

</table></td>
</tr>
</table>
<br />
<!-- /calendar --></div>
<!-- /container --></div>
</body>
</html>

========== /code ===========

Re: [zickey] Calendar populated with CMS Builder records

By Chris - August 31, 2010

Hi Zick,

Oops! My mistake. Days 1-9 were being stored in the array as 01-09 and looked up as 1-9, therefore weren't being found. To fix this, please change this line:

$day = date('d', strtotime($event['date']));

...to this:

$day = intval(date('d', strtotime($event['date'])));

I've also updated my post above.

Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Calendar populated with CMS Builder records

By Mikey - August 31, 2010 - edited: August 31, 2010

Chris, You are the man!
Thanks... works perfectly.

I've attached my calendar files and instructions for anyone interested in using this calendar. The files and instruction are provided as is, use at your own discretion. You assume full responsibility if you chose to utilize any portion of the code provided for the Zickey Calendar. Like you... I hate the fine print, but please read the TERMS.txt file.

Use it, expand it and please share any nice features you add to the Calendar with the InteractiveTools community on this thread.

Cheers, Zickey [:)]

Re: [zickey] Calendar populated with CMS Builder records

Zickey:

Very nice calendar! I'm working with it to see if I can add more features, such as highlighting "today", adding a "today" button and allowing the user to select a year (probably from a dropdown). I will post the code here for any to use.

Great post!

Ragi
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

Re: [chris] Calendar populated with CMS Builder records

By Mikey - September 9, 2010

Hey Chris or anyone who's reading,
Is there a way to add a link to the line I've marked as bold in the code below so that . $day . becomes a link using the following code?:
echo "<td class='CalDates'>"<a href="<?php echo $record['_link'] ?>">. $day . </a>"<br />";

Thanks, Zickey

Hi Zick,

There are two approaches you could take here:

1. Loop over every event in each day, skipping over elements which have a date which doesn't match the day.

2. Reorganize events into an array indexed by 'day', each element being a list of events on that day.

I've made some changes to your code with the second approach, which is a little more complicated but probably more sensible when dealing with lots of records.

Also, it makes sense to only return records from the database which are in the selected month. I've added a 'where' clause to getRecords() to do that. I had to move it below your $cMonth and $cYear code to do this.

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "C:/wamp/www/sb/CMS Builder/cmsAdmin/lib/viewer_functions.php";

?>
<!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;
}

// get event records for the selected month
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
'where' => mysql_escapef('MONTH(date) = ? AND YEAR(date) = ?', $cMonth, $cYear),
));

// organize events into an array indexed by 'day', each element being a list of events on that day
$eventsByDay = array();
foreach ($eventsRecords as $event) {
$day = intval(date('d', strtotime($event['date'])));
if (!array_key_exists($day, $eventsByDay)) { $eventsByDay[$day] = array(); }
$eventsByDay[$day][] = $event;
}


?>
<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">&nbsp;&nbsp;<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>&nbsp;&nbsp;</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 {
$day = $i - $startday + 1;
echo "<td class='CalDates'>". $day . "<br />";
// check if there are any events for this day
if (array_key_exists($day, $eventsByDay)) {
// list all events for this day
foreach ($eventsByDay[$day] 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'])) ?></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
}
}
echo "</td>\n";
}

if(($i % 7) == 6 ) echo "</tr>\n";
}
?>

</table></td>
</tr>
</table>
<br />
<!-- /calendar --></div>
<!-- /container --></div>
</body>
</html>


I hope this helps! Please let me know if you have any questions.

Re: [zickey] Calendar populated with CMS Builder records

By Chris - September 9, 2010

Hi Zick,

You can replace this line:

echo "<td class='CalDates'>". $day . "<br />";

...with this:

?><td class='CalDates'><a href="<?php echo $record['_link'] ?>"><?php echo $day ?></a><br /><?php

That might be a little easier to work with. Please let me know if you have any questions.
All the best,
Chris

Re: [zickey] Calendar populated with CMS Builder records

Here’s a rudimentary implementation for rollover ToolTips that I found using CSS.

Demo: http://thecmsbcookbook.com/calendar2.php

When you rollover the event titles, a tooltip shows the complete information available for the test events.

There’s no particular attempt to format the text.

Here’s the CSS Style that creates the ToolTip:
<style type="text/css">

* {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:1em; }
a:hover {background:#ffffff; text-decoration:none;}
a.tooltip span {display:none; padding:2px 3px; margin-left:8px; width:400px;}
a.tooltip:hover span{display:inline; position:absolute; border:1px solid #cccccc; background:#ffffff; color:#2b2b2b;}
</style>


Here's Juergen's original format for the tooltip:
<a href="#" class="tooltip">Here's the Tooltip<span>Suspendisse non metus id dolor accumsan bibendum. Aenean congue, libero at malesuada venenatis, lorem elit porttitor neque, quis sagittis ipsum purus vitae massa. Vivamus sed massa mi. Ut vitae odio ante, a convallis dui.</span></a>

And here’s the modification to the to Zickey’s original calendar code to invoke the rollover ToolTips (Note: My test section only had Title. Date, Location and Content fields. The link opens a detail page created by the code generator.):

// list all events for this day
foreach ($eventsByDay[$day] as $record) {
?>
<div id="calFonts">
<a href="#" class="tooltip"> <h1><?php echo $record['title'] ?></h1>
<span><?php echo $record['title'] ?><br />Time: <?php echo date("g:i a", strtotime($record['date'])) ?><br /><br />Where: <?php echo $record['location'] ?><br /><br />What: <?php echo $record['content'] ?></span></a>

<h3>Time: <?php echo date("g:i a", strtotime($record['date'])) ?></h3>
<!--<h3>Where: <?php echo $record['location'] ?></h3>-->
<p><?php echo maxWords($record['content'], 9); ?>... <a href="<?php echo $record['_link'] ?>">Learn More</a></p><br /><br /></div>


I'm sure that someone will easiy be able to improve on this.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php