The Telerik.Events assembly is distributed with Sitefinity. This module is responsible for adding, removing, deleting events from the Sitefinity system. This guide is meant to supplement the documentation that is available for Sitefinity. This document will cover the following:
- Files for events module
- Creating an event
- Deleting an event
- Adding meta fields to an event
- Adding the missing RSS Provider
As of the time when this was written, development documentation does not exist for the Telerik.Events assembly. The code samples where either “figured out” or derived from other samples. Thanks to Visual Studio®’s Intellisense® feature, Visual Studio®’s Object Browser and Reflector, I figured out most of it.
In order to work with events in Sitefinity you must add a reference to the Telerik.Events assembly. This assembly is already included in the Sitefinity install; it is mentioned in case you want to create a separate assembly for your events customization. The Telerik.Events.EventsManager handles all of the event management. An instance of the EventManager can be created like this.
After this, the eventsManager object will contain all the methods that you should need.
Files for events module
Like most (if not all) modules, the templates or user controls are keep in two directories underneath the /Sitefinity folder, the Sitefinity\Admin\ControlTemplates\<ModuleName>, in this case Events and Sitefinity\ControlTemplates\<ModuleName>. Within these directories, you will find a collection of files and one folder App_Resources. The App_Resources folder provides Sitefinity (or any .NET application) the ability to be localized. Keep in mind that if you want to change the text of a field or add a new field you will probably find the string in the corresponding .resx. In other words, if you are modifying CommandPanel.ascx you will find the resources to modify in \App_Resources\CommandPanel.ascx.resx. An example of this can be found in the section Adding meta field to an event.
The developers of Sitefinity seem to be consistent with the naming of files, they sort of follow this syntax <object><function>.ascx. So the insert form for an event can be found in the ControlPanelInsert.ascx file.
Admin\ControlTemplates\Events Files
This folder contains the files for the administrative portion of the events modules. While in most cases, except for adding meta fields to the event, you will not need to modify these files. However, if you are like me you like to know how things work.
Filename | Purpose |
---|---|
CategoriesField.ascx | Contains a list of event categories. |
CategoriesManagement.ascx | Provides functions to manage the categories; add, rename, etc. |
CategoriesSelector.ascx | |
CommandPanel.ascx | The command panel contains all of the functions for managing the events modules. This is the list that appears on the left hand side. Command panels load the Control Panels (middle of the interface). |
CommentsEdit.ascx | This control provides the ability to edit comments for an event. |
CommentsList.ascx | This control lists the comments for an event. |
CommentsView.ascx | This control lists a single comment for an event. |
ContentSelector.ascx | |
ContentVersionView.aspx | This control is used when viewing the version history of an event (or any generic content item) |
ControlPanelEdit.ascx | This control is used when editing an existing event. |
ControlPanelInsert.ascx | This control is used when adding a new event. |
ControlPanelList.ascx | This control is used to list all of the events. |
ControlPanelPermissions.ascx | This control is used to display / modify the permissions for events. This can be viewed by clicking on “Permissions” in the command panel. |
EditorTemplate.ascx | This control is used to display the RadEditor for the content of the event. This is used for all generic content. |
EventsScheduler.ascx | This is the control used when you first enter the events admin module or click on the “Events” link in the command panel. |
GeomappingEditor.ascx | This control is used to edit the geomappings for an event. This is used in ControlPanelInsert and ControlPanelEdit |
GeomappingSettings.ascx | This control is used to update the mapping api URLs and keys. This can be view by clicking on “Geomapping” settings in the command panel. |
NewContentDialog.ascx | I do not think this is used. This is carried over from the Generic Content controls, to create shared content. |
RecurringIntervalSelector.ascx | This is probably for a future release of the events module which would allow you to select a recurrence pattern. |
SelectContentDialog.ascx | I do not think this is used. This is carried over from the Generic Content controls, to share content. |
TagEditor.ascx | This is used when editing a tag on an event. |
TagsManagement.ascx | This control is used to manage the tags for the events. This can be viewed by clicking on the “Tags” link in the command panel. |
ControlTemplates\Events Files
This folder contains the files for the public/display portion of the events modules. These controls will be used to display the events on the public facing site.
Filename | Purpose |
---|---|
ArchiveTemplate.ascx | |
CategoriesList.ascx | Displays a list of event categories and the number of events in that category. Not displayed in the “Community” template. |
CommentsList.ascx | Displays the list of comments for an event. |
CommunityContentViewItemList.ascx | This control is used by the Events page in the “Community” template to display a list of events. |
CommunityContentViewSingleItem.ascx | This control is used to display and event that is clicked in the CommunityContentViewItemList control. |
ContentViewItemList.ascx | This control is used by the Upcoming Events page in the “Community” template to display a list of events. |
ContentViewSingleItem.ascx | This control is used to display and event that is clicked in the ContentViewItemList control. |
eventsCommonLayout.css | The Cascading Style Sheet (CSS) used for the event pages. |
EventsScheduleView.ascx | Displays the events in a calendar view. |
HomeContentViewItemList.ascx | This control is used to display the events in on the home page for the “Community” template. |
TagsList.ascx | Displays the lists of tags for an event. |
Creating an event
In order to create an event in Sitefinity using the Telerik.Events assembly, you must follow a few steps.
- Create an instance of the EventsManager class with the correct provider…
- Create a new generic content object…
- Update the meta data…
- Optionally, get/create an event category, then update the metadata…
- Save the content…
Utility method for creating an event.
Deleting an event
In order to delete an event using the Telerik.Events assembly, you must get an instance of the Telerik.Events.EventsManager object. As you will see the code sample below, the eventsManager class has one method called DeleteEvent() which has 2 overloads.
The first overload requires two parameters, the Event GUID which is the Event.Id and a boolean which indicates if the manager should delete the associated generic content.
The second overload requires two parameters, the Event which is the Event.Id and a boolean which indicates if the manager should delete the associated generic content.
Adding meta fields to an event
Adding meta fields to the events module is a 5 step process which involves editing the web.config file, editing the administration control templates, and the public display templates.
For this example we will add a Short Text meta field call ClickToAttendId that we want to be displayed as part of a HTML hyperlink similar to this http://www.clicktoattend.com/invitation.aspx?code=ClickToAttendId
Step 1: Edit the web.config file.
Open the web.config file and search for <metaFields>. This is where Sitefinity loads the list of meta tags for each of the generic content modules. You should find a series of “add” XML elements. These “add” elements take 6 attributes, key, valueType, searchable, sortable, and defaultValue.
Element | Purpose |
---|---|
key | The key is made up of two parts, modulename.fieldName. So Events.Title means the Title meta field of the events module. |
valueType | The type of data that will be stored. The following are valid types:
|
visible | Indicates whether it will be shown in the admin section of the events module. |
searchable | Indicates if you can search on this field. |
sortable | Indicates if this field can be sorted on. |
defaultValue | The default value for this field. |
Add a XML element to the <metaFields> section that looks like this
Save an close the web.config.
Step 2: Edit the Admin\ControlTemplates\Events\ControlPanelEdit.ascx.
Where you place the HTML markup depends on where you think the control needs to be. At the minimum it needs to be placed after the <p class=”button_area top”> code block and before the block…
An example of the markup could look like this.
The <h3>< section is used for the title of grouping of the data.
The <fieldset class=”set”> element is used to contain the label and text box for the ClickToAttendId.
Notice that there is a consistent naming theme for the HTML controls, lblfieldName for the label (this is optional), the text box must be the fieldName or Sitefinity will not be able to update it.
Save the file.
Open up App_Resources\ControlPanelEdit.ascx.resx and add in any of the resources that you referred to in this sample, namely ClickToAttendId.
Step 3: Edit the Admin\ControlTemplates\Events\ControlPanelInsert.ascx.
The ControlPanelInsert.ascx should be edited in the same way that the ControlPanelEdit.ascx was edited.
Step 4: Edit the ControlTemplates\Events\CommunityContentViewSingleItem.ascx
The markup can be placed anywhere inside the div block <div class=”sf_eventContent”>.
A sample of the markup could be.
Just as in the administrative templates, in order to display the metadata there should be a control on the form that matches the name of the metadata.
Save the file.
If neccessary, open up the App_Resources\ContentViewSingleItem.ascx.resx file and add whatever resources you require.
Step 5: Edit the ControlTemplates\Events\ContentViewSingleItem.ascx
For some reason, the markup of the ContentViewSingleItem is a bit different.
The markup can be placed anywhere inside the div block <div class=”sf_eventContent”>.
A sample of the markup could be.
Save the file.
If neccessary, open up the App_Resources\ContentViewSingleItem.ascx.resx file and add whatever resources you require.
Adding the missing RSS Provider
Coming soon…