10375 Posts in 2190 Topics by 1707 members
| Go to End | Next > | |
| Author | Topic: | 5178 Views |
-
Re: Event Calendar Widget on Home page

7 May 2011 at 2:39am
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
-
Re: Event Calendar Widget on Home page

8 May 2011 at 5:37am Last edited: 8 May 2011 5:48am
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 -
Re: Event Calendar Widget on Home page

8 May 2011 at 8:43pm
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
-
Re: Event Calendar Widget on Home page

10 May 2011 at 7:59am
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 -ADatabase 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?? -
Re: Event Calendar Widget on Home page

10 May 2011 at 2:15pm
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
-
Re: Event Calendar Widget on Home page

10 May 2011 at 2:28pm
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
-
Re: Event Calendar Widget on Home page

10 May 2011 at 7:12pm
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!
-
Re: Event Calendar Widget on Home page

11 May 2011 at 12:39am
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?? :-/
| 5178 Views | ||
| Go to Top | Next > |

