10931 Posts in 2614 Topics by 1810 members
Page: 1 2
|Go to End||Next >|
25 August 2011 at 6:33am Last edited: 27 August 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:
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:
[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
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?
27 August 2011 at 5:05am
I've updated orginal post to better explain my problem
29 August 2011 at 12:12am Last edited: 29 August 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.
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 %>
<% end_if %>
<% if Calendar2 %>
<% end_if %>
Cannot believe how long i spent trying to modify calendarUI.class.php, when this was supported all along.
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.
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
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.
Page: 1 2
|Go to Top||Next >|