Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Event Calendar Widget on Home page


Reply

34 Posts   6496 Views

Avatar
elgordo

7 May 2011 at 2:39am Community Member, 70 Posts

hi tchintchie

I am using the EventCalendar with Silverstripe 2.4.5 with no issues. However you will probably need to clone the version that is in github and not used a versioned created from Subversion

The github page is here

https://github.com/unclecheese/EventCalendar

Regards

Gordon

Avatar
tchintchie

8 May 2011 at 5:37am (Last edited: 8 May 2011 5:48am), Community Member, 63 Posts

Hi Gordon!

Thanks for the hint tried it out but got the same result :-( here´s my code:

class HomePage_Controller extends Page_Controller {
   

function UpcomingEvents()
{
return DataObject::get_one("Calendar")->upcomingEvents(5);
}

}

and on my HomePage.ss:

<div id="Layout">
<div id="Banner"> <img src="themes/reisen/images/welcome.png" alt="Homepage image" /> </div>
$Layout
<% control UpcomingEvents %>
<h3>$_Dates</h3>
<h2><a href=$Event.Link">$Event.Title</a></h2>
<% end_control %>
</div>

any idea what i´m doing wrong??

thx for your patience :-)
tchintchie

Avatar
elgordo

8 May 2011 at 8:43pm Community Member, 70 Posts

Your function and template are fine, as I am seeing results on a test server on my laptop. As such it must be a data issue.

1) How many calendars in your database do you have? The reason I ask is that

return DataObject::get_one("Calendar")->upcomingEvents(5);

infers you are getting the first calendar, and your events may be attached to another calendar.

The following SQL should indicate whether this is the case:

select ID, CalendarID from CalendarEvent;

2) Create a test event that is miles in the future, just to ensure there is at least one future event

Avatar
tchintchie

10 May 2011 at 7:59am Community Member, 63 Posts

as far as i know i only use this one calendar (have re-installed it two or three times though...) my SQL returned this:

mysql> use rs_reisen
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select ID, CalendarID from CalendarEvent;
+----+------------+
| ID | CalendarID |
+----+------------+
| 8 | 0 |
| 9 | 0 |
| 29 | 0 |
+----+------------+
3 rows in set (0.02 sec)

now if only i knew what this meant :-) is there anything wrong with my database then??

Avatar
elgordo

10 May 2011 at 2:15pm Community Member, 70 Posts

To check the calendar ID in the code you can try changing

function UpcomingEvents()
{
return DataObject::get_one("Calendar")->upcomingEvents(5);
}

to

function UpcomingEvents()
{
$calendar = DataObject::get_one("Calendar");
error_log("Calendar id:".$calendar->ID);
return $calendar->upcomingEvents(5);
}

This should log the ID of the calendar in the error log if you have error reporting turned up far enough.

Another option to try might be changing

$calendar->upcomingEvents(5)

to

$calendar->CalendarEvents

which I think will return all of the events associated with the calendar.

Looking at the SQL results I am surprised to see a CalendarID of 0, but checking locally mine are 0 also (I was expecting the calendar ID). I will need to dig further

Avatar
elgordo

10 May 2011 at 2:28pm Community Member, 70 Posts

Ah, ok it looks like the parent child relationship is used instead.

Execute the following in your database

select ID, ParentID from SiteTree_Live where ClassName = 'CalendarEvent';

I am seeing the likes of this:

+------+----------+
| ID | ParentID |
+------+----------+
| 6634 | 6418 |
| 6600 | 6418 |
+------+----------+
2 rows in set (0.00 sec)

If you have multiple ParentIDs then you may well have more than one calendar.

You can check the parent type like this

select ID, ClassName from SiteTree_Live where ID=6418;
+------+-----------+
| ID | ClassName |
+------+-----------+
| 6418 | Calendar |
+------+-----------+
1 row in set (0.00 sec)

Change the ID obviously depending on your results

Avatar
tchintchie

10 May 2011 at 7:12pm Community Member, 63 Posts

Wow thank you so much for all your efforts!!! I´m not in front of my working machine right now but will check as soon as I get there and let you know if it worked!

anyways I owe you :-)

cya!

Avatar
tchintchie

11 May 2011 at 12:39am Community Member, 63 Posts

mysql> select ID, ParentID from SiteTree_Live where ClassName = 'CalendarEvent';
+----+----------+
| ID | ParentID |
+----+----------+
| 8 | 7 |
| 9 | 7 |
| 29 | 7 |
+----+----------+
3 rows in set (0.03 sec)

mysql> select ID, ClassName from SiteTree_Live where ID=7;
+----+-----------+
| ID | ClassName |
+----+-----------+
| 7 | Calendar |
+----+-----------+
1 row in set (0.03 sec)

ok, guess this means I only have one calendar then??

so will changing:
$calendar->upcomingEvents(5) to $calendar->CalendarEvents change anything?? :-/