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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

LiveCalendarWidget Help


Go to End


11 Posts   3811 Views

Avatar
redactuk

Community Member, 117 Posts

25 August 2011 at 6:33am

Edited: 27/08/2011 5:06am

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

Avatar
redactuk

Community Member, 117 Posts

27 August 2011 at 5:05am

I've updated orginal post to better explain my problem :)

Avatar
redactuk

Community Member, 117 Posts

29 August 2011 at 12:12am

Edited: 29/08/2011 2:12am

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.

Avatar
redactuk

Community Member, 117 Posts

29 August 2011 at 6:26am

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 August 2011 at 5:58am

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

Avatar
mierla

Community Member, 16 Posts

12 October 2011 at 4:41am

@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. :)

Avatar
redactuk

Community Member, 117 Posts

14 October 2011 at 11:39pm

@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 :(

Avatar
mierla

Community Member, 16 Posts

15 October 2011 at 12:30am

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.

Go to Top