“Who knows where the time goes?” (Sandy Denny)
Installation
When I installed this to try it out a while ago I found that I needed to make some changes to get it to work properly. While reminding myself what these were I accidentally found that there is now a new version available, see here: http://ismail.umbraco.net/2007/9/5/event-calendar-for-umbraco-v3.aspx.
So download and install this. (Developer/right click Macros/Import Package). For the record since I suspect I may want to play with this later, the package has installed:
- Document Type: Events (plus one sample node)
- Document Type: Event (plus one sample node)
- Macro: Events Calendar
- File: \bin\Umbraco\EventsCalendar.dll
- File: \usercontrols\eventscalendar\eventsCalendar.ascx
- File: \usercontrols\eventscalendar\events.xsd
- File: \usercontrols\eventscalendar\events.xslt
- File: \usercontrols\eventscalendar\images\info.gif
- File: \config\calendar.config
Make the configuration changes given in Ismail’s blog:
- Update calendar.config with node id of the Events page created by the package install.
- Update webconfig with the two entries relating to calendar.config (immediately following the similar ones for urlrewritingnet).
Problems
Unfortunately there are a few problems, in particular the Document Types and/or test pages in the package do not seem to be compatible with the Creative Website starter kit which I have installed.
- Firstly the “Events” page was loaded directly under “Content”, which appeared to interfere with the Navigation macro in the starter kit.
- Secondly, it took a while to realise that the call to the EventsCalendar macro which I was looking for in the template was in fact buried in the (hidden) text of the contents field. (This needs altering of course since the Start Node Id needs to be set according to the current site.) Even then I could not get the page to display anything – it kept giving Server Null Reference Errors.
- Thirdly I also could not get the test Event page to display anything. It gave either a complete blank, or again a Null Reference Error.
- Also one cannot as recommended put a Form Tag in the Master template, because there are other Form tags in lower level places. I put these into the template for my calendar page instead. (NB one must use the Umbraco macro <?ASPNET_FORM> </?ASPNET_FORM> and not straight HTML <Form> </Form> tags.)
I therefore created new Calendar and Exhibition document types, and sample documents of each type from scratch.
Summary
In summary, after installation carry out the following to get the Calendar operating:
- Create a Document Type to hold the Calendar control, and an associated Template. There is nothing very special about the Document Type, but the Template needs to include the following to invoke the control.
<?ASPNET_FORM>
<div>
<?UMBRACO_MACRO macroAlias="EventsCalendar" EventsStartNode="1095" ResourcePath="/usercontrols/eventscalendar/">
</?UMBRACO_MACRO>
</div>
</?ASPNET_FORM>
- Set the Events Start Node parameter to the Node Id of wherever you are going to hang your Events from. (Can be the Calendar itself if the Events hang under it.)
- Create a Document Type (and Template) for your events. (Pity the package has already taken “Event”.) The important thing here is to include the following fields which are used by the events.xslt file:
- Event Start Date (eventDate) DatePicker
- Event End Date (eventEndDate) DatePicker
- Make the configuration changes given in Ismail’s blog:
- Update calendar.config with node id of the Events Start Page, as above.
- Update webconfig with the two entries relating to calendar.config (immediately following the similar ones for urlrewritingnet).
- Edit the events.xslt file (Line 14) to use the Node Alias of your new event Document Type.
- Edit the events.xslt file on Line 25 to take out the / immediately after the opening tag <URL>. This is acknowledged as a bug on Ismail’s blog.
Styling
Having got it working, I decided to tweak the presentation style a bit.
- I prefer the overall effect with the following additions made to the eventscalendar.ascx file:
- Add: nextprevformat="shortmonth" borderwidth="2px" bordercolor="#000000"
to the datacalendar definition (Line 3).
- Add: borderwidth="2px" Height="2em"
to the <titlestyle> (Line 4)
- I attempted to put these styling operations into a class, and use a CSS stylesheet to hold the detail, but it didn’t like that. Don’t know why.
- TODO: I plan to come back and look at changing the colour of item entries for different types of event, but that needs some more planning on how to organise my events.
Recurrence
Some events, notably courses, only happen one day a week for say a term. We need to add a mechanism to deal with this.
- Create a new Datatype called “lacRecurrence”. Rendercontrol as RadioButtonList, Database type as Integer, Prevalues set to Daily (15 (in my case)), and Weekly (16).
- Add to relevant Document Types as required.
- Add code to events.xslt which reads the value and sets a variable number of days at which to repeat the entry, rather than the fixed value of one.
In general such recurring events do not occur on Sundays (in our case). However some do, so add a further True/False field called lacOpenSundays, and only add a repeated event on Sunday if this is set to be true.
Node selection
I expect to have several different Document Types to be included in the Calendar, so rather than selecting nodes by nodeType I have selected all nodes having a data item “eventDate”. This incidentally also protects against users who don’t fill in the date, otherwise the date difference calculations blow up.
Implemented Ismail’s suggestion to ignore old events, I decided to skip anything where the start date was older than 6 months ago.
While I am at it, also add a check that the end date exists before trying to calculate whether more than one entry is required. If there is no end date, then display it as if the end date were equal to the start date. Again this allows definition of an Event which only has a single date to be entered.