Jump to:

10929 Posts in 2613 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Event Calendar Widget on Home page

Discuss all other Modules here.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 6300 Views
  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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

  • tchintchie
    Avatar
    Community Member
    63 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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

  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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

  • tchintchie
    Avatar
    Community Member
    63 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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??

  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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

  • elgordo
    Avatar
    Community Member
    70 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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

  • tchintchie
    Avatar
    Community Member
    63 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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!

  • tchintchie
    Avatar
    Community Member
    63 Posts

    Re: Event Calendar Widget on Home page Link to this post

    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?? :-/

    6300 Views
Page: 1 2 3 4 5
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.