Jump to:

10846 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » LiveCalendarWidget Help

Discuss all other Modules here.

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

Page: 1 2
Go to End
Author Topic: 1175 Views
  • redactuk
    Avatar
    Community Member
    115 Posts

    LiveCalendarWidget Help Link to this post

    My BookingHolder extends Calendar, and BookingEvent extends CalendarEvent. I have also extend Page to create BookingPage, which I've allowed as a child of BookingHolder in order to display some static information pages.

    What I'm trying to do is create two BookingHolders at the root level of my website tree. Using and adapted version of the event resources module every booking (event) is assigned a Resource (room event takes place in). As my understanding is that all event records are stored in the same table, what I've done is modified my templates so each of my two BookingHolder(s) only displays events assigned to a particular resource. So I effective have:

    [root]/Calendar1/Page1
    [root]/Calendar1/Event1
    [root]/Calendar1/Event2

    [root]/Calendar2/Page2
    [root]/Calendar2/Event3
    [root]/Calendar2/Event4

    Now all of this works fine, with one exception, and that's the LiveCalendarWidget when used on my custom pages. I works fine when directly used via BookingHolder or Booking Event, but not my BookingPage. When used on BookingPage it DOES work for Calendar1/Page1, but when used on Calendar2/Page2 it's still linking to my Calendar1 URL. A Debug::dump($this->calendar); via CalendarUI.class shows:

    BookingHolder Object
    (
    [event_class:protected] =>
    [event_object:protected] =>
    [event_datetime_class:protected] =>
    [event_datetime_object:protected] =>
    [start_date:protected] =>
    [end_date:protected] =>
    [filter_fields:protected] =>
    [destroyed] =>
    [record:protected] => Array
    (
    [ClassName] => BookingHolder
    [Created] => 2011-08-14 22:45:58
    [LastEdited] => 2011-08-20 17:52:30
    [URLSegment] => calendar1
    [Title] => Calendar1
    [MenuTitle] => Calendar1
    [Content] =>

    As you can see the problems is that the URLSegment and other details are those for my Calendar1. I've actually swapped the order of the BookingHolders in the site tree to put Calendar2 before Calendar1 and the same thing happens. So basically the LiveCalendarWidget is always using details from the FIRST instance of CalendarHolder in the tree.

    Can anyone help me with how i may work around this? Presumably I need to make some changes to public function __construct in LiveCalendarWidget, but I'm struggling to see how to change this. Anyone able to help?

    Thanks

  • redactuk
    Avatar
    Community Member
    115 Posts

    Re: LiveCalendarWidget Help Link to this post

    I've updated orginal post to better explain my problem

  • redactuk
    Avatar
    Community Member
    115 Posts

    Re: LiveCalendarWidget Help Link to this post

    Well this issue does not occur with the default CalendarWidget. Looking at the code it seems that CalendarWidget knows where it is as the URLSegment is set according to the controller, but the same does not happen with the LiveCalendarWidget. So what I need to work out now is how to fix the LiveCalendarWidget.

  • redactuk
    Avatar
    Community Member
    115 Posts

    Re: LiveCalendarWidget Help Link to this post

    Finally resolved this.

    For the benefit of anyone else finding this post and realising what I was trying to do, my problem was resolved by finding this post http://www.silverstripe.org/all-other-modules/show/8557 indicating that you can pass a URLSegment to LiveCalendarWidget!

    So in my case as I'm using one custom page template, I created two functions to test the calendar currently being viewed, then in the template added:

    <% if Calendar1 %>
    $LiveCalendarWidget(calendar1)
    <% end_if %>
    <% if Calendar2 %>
    $LiveCalendarWidget(calendar2)
    <% end_if %>

    Cannot believe how long i spent trying to modify calendarUI.class.php, when this was supported all along.

  • UncleCheese
    Avatar
    4085 Posts

    Re: LiveCalendarWidget Help Link to this post

    Ha. Awesome. Good to see that functionality get used. I knew someone would get something out of it.

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • mierla
    Avatar
    Community Member
    16 Posts

    Re: LiveCalendarWidget Help Link to this post

    @redactuk - In your system is it possible to book a resource/date from the frontend? I realize this is a bit off-topic, but this is something I've been struggling with for months and it sounds like you may have done it. I'd love to know how if you're willing to share. If not, that's cool too.

  • redactuk
    Avatar
    Community Member
    115 Posts

    Re: LiveCalendarWidget Help Link to this post

    @mierla - No, bookings are made via the admin area as standard.

    I have to say though we are already looking for another solutions, as while this calendar works ok for a couple of bookings, the problem is that every booking must be added as a page, therefore after the 10 bookings the list of pages in the admin area tree just becomes silly. Our calendar regularly now has 30 plus entries and navigating the admin tree is very frustrating

  • mierla
    Avatar
    Community Member
    16 Posts

    Re: LiveCalendarWidget Help Link to this post

    Thanks for the reply, @redactuk.
    That's something I'm running into too. Things get pretty unwieldy pretty quickly with the event=page system. The more I mess with it, the more I come to the conclusion that EventCalendar, while awesome, is not the right fit for this particular problem.

    1175 Views
Page: 1 2
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.