Event Calendar

10 posts by 3 authors in: Forums > CMS Builder
Last Post: August 21, 2009   (RSS)

By KCMedia - July 21, 2009

Hi

I have a need for this kind of calendar but i am having problems trying to get what i need.

The requirements in CMS are

Month "list" all the months of the year
Day "list" fri, sat, sun, mon only
Date "date"
Title "text"

I can get that working right but getting it to show is the problem.

I want to be able to group all the dates together and lsit them as per this example php file.

The problem is getting them to display right i need to group the months together and show all the dates that in the cms for that month and then so on for each month after that.

The starting month will always be Sept on though that but sometimes there will be missing months.

thanks

Craig
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

test_003.php 1K

Re: [kcmedia] Event Calendar

By ross - July 21, 2009

Hi there.

Thanks for posting!

The first thing you'll want to do is just have that section sorted on the month field so all your dates are grouped by month. That can be done in either the section editor or right in the viewer code on your list page.

Once you have that setup, I assume you want to have your output look something like this:

September
- date 1
- date 2
- date 3
October
- date 1
- date 2
- date 3

So each month name only shows up once. To do that, you'll need to create a variable to keep track of which month you are currently displaying. The basic idea will look like this:

<?php $lastMonth = ""; ?>
<?php foreach($eventRecord as $record): ?>
<?php if ($record['month'] != $lastMonth): ?>
<?php echo $record['month']; ?>
<?php endif ?>
<?php echo $record['date']; ?>, <?php echo $record['date']; ?>
<?php endforeach ?>


You'll need to make sure the foreach part is the same as what you already have.

Does that all make sense? Let me know what you think :).
-----------------------------------------------------------
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: [kcmedia] Event Calendar

By ross - July 22, 2009

Hi there.

Based on your code, I'll get you to try this:

<?php $lastMonth = ""; ?>
<?php foreach ($fishing_calendarRecords as $record): ?>
<?php if ($record['month'] != $lastMonth): ?>
<?php echo $record['month']; ?>
<?php endif ?>
<?php echo $record['day']; ?>, <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?>
<?php endforeach ?>


Just replace all the code you have in your post with everything in my post. Let me know how you make out :)
-----------------------------------------------------------
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] Event Calendar

By KCMedia - July 22, 2009 - edited: August 17, 2014

Hi Ross

I have put that in there have a look what happens now



Hows do i get it into the tables and also get the other feilds to work also.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Event Calendar

By ross - July 24, 2009

Hi

That's odd. Could you post me a copy of that page so I can see how the code looks?

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] Event Calendar

By KCMedia - July 26, 2009

Hi Ross

Here is the code

<?php

require_once "cmsAdmin/lib/viewer_functions.php";

list($fishing_calendarRecords, $fishing_calendarMetaData) = getRecords(array(
'tableName' => 'fishing_calendar',
'loadUploads' => '0',
'allowSearch' => '0',
));

?>

<?php $lastMonth = ""; ?>
<?php foreach ($fishing_calendarRecords as $record): ?>
<?php if ($record['month'] != $lastMonth): ?>
<?php echo $record['month']; ?>
<?php endif ?>
<?php echo $record['day']; ?>, <?php echo date("jS", strtotime($record['date'])) ?>
<br />
<?php endforeach ?>


<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="center">&quot;Month&quot;</td>
</tr>
<tr>
<td>&quot;Day&quot;</td>
<td>&quot;Date&quot;</td>
<td>&quot;Text&quot;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Event Calendar

By Dave - July 27, 2009

Hi Craig,

If you like I could just have a look at the code directly. Just email CMS and FTP login details and a link to this post to dave@interactivetools.com. Note: email, don't post login details to the forum.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [ross] Event Calendar

By KCMedia - August 20, 2009 - edited: August 17, 2014

Hi Ross

Sorry for the delay here is a copy of the code still cant get this to work here is the link to the page that is being displayed

<?php

require_once "/home/botany/domains/botanybaygamefishing.com.au/public_html/cmsAdmin/lib/viewer_functions.php";

list($fishing_calendarRecords, $fishing_calendarMetaData) = getRecords(array(
'tableName' => 'fishing_calendar',
'loadUploads' => '0',
'allowSearch' => '0',
));

?>


<br />


<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" align="center"><?php $lastMonth = ""; ?>
<?php foreach ($fishing_calendarRecords as $record): ?>
<?php if ($record['month'] != $lastMonth): ?>

<?php endif ?>
</td>
</tr>
<tr>
<td><strong><?php echo $record['month']; ?></strong> &nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="100"> <?php echo $record['day']; ?></td>
<td width="40"><?php echo date("jS", strtotime($record['date'])) ?></td>
<td width="400"><?php echo $record['text'] ?> <?php endforeach ?></td>
</tr>
</table>

Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Event Calendar

By ross - August 21, 2009 - edited: August 21, 2009

Hi Craig

I think you've got most of the code you need, but it's gotten a little mixed up :).

The "if" block you have is what determines whether to display the month name. It basically checks to see if the month of the current record equals the month of the previous record. The problem in your table is that the part that displays the month isn't actually in the "if" block so it just gets displayed every time regardless.

What I'll get you to do first is take this piece of code out of your table:

<strong><?php echo $record['month']; ?></strong> &nbsp;

and move it up a couple lines so that you have this:

<?php if ($record['month'] != $lastMonth): ?>
<strong><?php echo $record['month']; ?></strong> &nbsp;
<?php endif ?>


Next, I just noticed that there is one bit of code missing from my original idea. You need to load the month of the current record into that $lastMonth variable. To do that, you use this:

<?php $lastMonth = $record['month']; ?>

That goes right before the end of the foreach loop like this:

<?php $lastMonth = $record['month']; ?>
<?php endforeach ?>


Try making those two adjustments and let me know how you make out :).
-----------------------------------------------------------
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/