Events calendar

14 July 2006 by Ismail

Alot of people including myself have asked on the forums about an events calendar.  I eventually built one myself.  You can get it
here.  The zip has binary and source. 

How does it work?

The basic calendar is a control that I found on code project  written by
Mike Ellison you can find it here.  Sample 3 of the calendar has example where it binds to datasource that is populated by XML. That give me the idea
to pull umbraco events node xml and feed it into the calendar via the xmlreader.  In the source if you look at the function GetEventData
you can see how thats done.  The eventsStartNode is parameter passed into the control ie parent node where all events live.


 

In the transfromXML function using the events.xslt and in the GetEventData and using the events.xsd the Umbraco xml
is massaged into format that can then be pushed into dataset. 

Initally I was doing simple caching but then decided to do some overkill with Microsoft application blocks caching because I had not
used the caching block before thought it would be good learning experience.  The control itself is templated you can see this in the
eventsCalendar.ascx so you can make it look nice.  On a page using the calendar if you pass into it querystring parameters debug=1 so you can see the xml before and after
useful for debugging.  Also Refresh=1 and it will clear the cache however first load will be slow. 

See below for screen shot of the calendar in action:

events calendar preview

How to Install.

Copy the contents of the calender/bin dir to the bin dir of your Umbraco install.  Copy the /calendar/eventscalendar directory to your usercontrols directory.
In your web.config you need to add the following extra entries to get the caching to work :

Copy the cachingConfiguration.xml file into the root of your website.

 Create macro call it what you like point it to the eventscalendar.ascx make sure you update properties.  EventsStartNode type content picker and ResourcePath type text this value will be /usercontrols/eventscalendar/ basically tells the control where to look for xsl and xsd.   

This bit is very important!!  You will need to modify the events.xslt to match the parameters of your events document type.

In the xslt you will have to change this so that your event items are picked up.

  also ensure that all your field names are updated in the xsl.  One key point in the xsl is the template processSpanNodes. Basically this is a hack
to get Mike's calendar to have start and end dates for events it assumes your events have a start and end date.

Apologies if instructions are a bit naff post a comment if any issues sugggestions etc.

 


10 comment(s) for “Events calendar”

  1. By the way,

    I had to "modify" your form to allow me to post because your "code" regions cause validation errors so no posting is possible.

    David
  2. If one has umbraco 2.1.4 installed then the Events Document type can be exported and included in the events calendar archive for import. this will lessen the confusion.
    I did this when I was duplicating websites from one server to another.
  3. Hello,

    What kind of page do you use to "host" the control? I created a template to run the macro, and tried using that template on a TextPage, but get an error saying the control must be placed inside a form tag with runat=server.

    I'm close to getting it to work though!

    Thanks,

    David
  4. Thomas,

    1) If no end date is given, it raises and error ( Unfortunately the date picker cannot be made mandatory I was going to look at updating source of datapicker so we could have mandatory one. If I get time I will get onto this so that we always have a date. )

    2) URLs in the calendar is not correct (missing domain). It’s probably due to my misconfiguration of Umbraco rather than anything else ( I think this is caching I have had same problem which has then fixed itself )

    3) Icons not showing (probably same as 2.) In your umbraco install do you have {umbraco install dir}/usercontrols/eventscalendar/images if not then create that dir and copy over images also ensure in the control when u drop it on page that u set the resource url path.

    With regards to type of event you need to possibly create new drop down field in your document type and have event type there. In your xslt add this value might need to do prevalues to get the actual selected value and using xsl choose set the right image. You would then need to update the line src='<%# ResourcePath %>images/info.gif' in the usercontrol to <%# Container.DataItem["EventImage"] %> dont forget to update the xsd.

    The calendar was a quick hack during some spare time I have not used it yet myself and its not upto the usual high standard of other umbraco packages. :-{
  5. Hi Ismail.

    I had a peek at the source, and found the reasons why it didn't work as expected.

    First there was a small inconsistency but the "released" control, and the source. The ready made eventsCalendar.ascx was missing the <%# ResourcePath %>.

    Second, I think there might be a small bug in the umbraco.library:NiceUrl(@id), which is used in the XSLT. It returns //event/eventitem.asx (notice the double //).

    I am sure this could be handled but the assigning domain feature, but I don’t know how.

    Anyway, just to let you know, that with these minor changes, I got it to work after all.

    Now (if time permits) I will se if I could dynamically change the icon, second do some better formatting on the events I the calendar, and at last – set the end date to start date if no end date is given
  6. This looks great, however as one mentioned on the deprecated mailing list, this is only half the package, and I could use some help in creating the event documents with the right properties.
    But it looks great, and was just what I needed, perhaps someday this would be available as an Umbraco package, ot perhaps just included as a standard in the upcoming version.
  7. Thomas,

    To get the calendar to work as is you need to create an events folder doesnt matter about the fields in it, this will be root events folder. Then create new event document type will have following structure:

    1. Document type alias Event Item
    2. Fields eventDate of tpye datepicker, eventEndDate also datepicker and bodyText which will be rich text field.

    That should get it running with no changes to xslt. Any problems post them here and I will try to fix. I know one person has already got it running
  8. Hi Ismail,

    Well I thought that I had done this, but then I did it again from scratch.
    Had to reset the IIS though a couple of times, because some old nodes still was cached somehow.
    So I got it to work, but there is still some minor obstacles.
    1) If no end date is given, it raises and error
    2) URLs in the calendar is not correct (missing domain). It’s probably due to my misconfiguration of Umbraco rather than anything else
    3) Icons not showing (probably same as 2.)
    Is there a way to alter the event type eg, Birthday, holiday og info, what am I missing here?
  9. why not use Wink:
    http://www.debugmode.com/wink/
    and show us how you did it.
  10. Hey nice one. Never heard of or used wink before but once i get a free moment ill get onto it.

Leave a comment


(not shown)


(optional - remember http://)


Stop those damn spammers