JosephGuadagno.net

Microsoft Visual C# MVP, Vice President of INETA North America, and Founder of Southeast Valley .NET User Group

T-Mobile WiFi Calling

A month or so ago I signed up for this new T-Mobile plan that allows you to use your cell / mobile phone to make unlimited calls from almost any WiFi connection.  The reason I say almost is because there are two types of WiFi connections it will not make, a secured WiFi network that you do not have the security key for and any "free" WiFi connections that require you to accept the terms of use (most public access points).  When I saw this deal I signed up almost immediately. The idea that you can be on the road using your normal cell phone tower and them walk in to you house and seamlessly have the call transferred to your wireless network was awesome. So I purchased four Samsung Katalyst T-739 phones which have WiFI / UMA calling built in and my journey began.

Since then I have had two months of unreliable WiFi calling connectivity. My first connection attempts were with my AirLink AR430W SuperG Wireless router that I purchased for $15.00 dollars at a local Frys Electronic store. With this router I would get sporadic WiFi/UMA connectivity on all four phones.  Some of them would connect, some of them would not. I would get one of a few T-Mobile errors; W002 and W010.  After googling for days and weeks, there was not a lot of information about these errors on the Internet. Most of the errors pointed to Blackberry connectivity issues and that errors W002 and W010 means that the device could not get an IP address which was quite strange because both laptops, my Wii and Xbox 360 all connected fine.  So I began my troubleshooting...

First I tried to connect to a friends un-secure router, every connection attempt was successful and I was making calls but this was not legal. So I tried to un-secure my wireless network, this worked for some of the phones some of the time. I tried changing the network beacon timeout, this worked for some of the phones some of the times.  The phones would sometimes connect after rebooting the router but this was unacceptable.  After about a month I decided it was my cheap $15 dollar router, so I went out and purchased a TrendNET TEW-631BRP 300Mbps Wireless N Broadband route. I continued to have the the same issues as above so I went back to Google and found a few sites that suggested to turn off MAC filtering, this was not applicable to me, or to try to assign static IP addresses to the phone so I tried this but no dice.  After about six weeks of troubleshooting and phone tag with the T-Mobile WiFi calling help desk we came up with a solution.

The solution

It turned out that the sporadic access was because I had the router set to automatically determine a channel.  The T-Mobile WiFi/UMA service will only work with channels 1,6, or 11, which I why it connected to my neighbors router (channel 6).

Here are all of the settings that you can apply to router to make it function similarly to the T-Mobile branded LinkSys router.

Setting Value
Beacon Period 100
RTS Threshold 2347
Fragmentation Threshold 2346
DTIM Interval 1
Wireless Channel (try in this order) 11, 6, 1
For a secure network WPA 2 is preferred over WEP

I hope this helps solve some of your problems and that T-Mobile documents this somewhere.

New Sitefinity tool created

As some of you know, I have the Southeast Valley .NET User Group web site running on Telerik's Sitefinity product.  The product itself is awesome but needs a few features here an there... One of which is a mechanism to get data into Sitefinity quickly. Luckily, Sitefinity provides a pretty extensive API for you to develop against. So with some free time, the little I have, I put together a Data Importer tool for Sitefinity. This tool will allow you to import data from a Comma Separated file into any Sitefinity generic provider.

The project is open source and available at http://www.codeplex.com/SEVDNUGDataImporter please report any problems or feature request there.

Enjoy!

Creating a new Sitefinity generic content module

So, I heard that the Sitefinity application had this generic content module that was pretty easy to  use to create your own module with. Why do you need to create a new generic content based module you ask?  There a few answers to that question.  I created a new generic content based module because I wanted to track all of the discounts that were offered to the Southeast Valley .NET user group and since free time is a something I do not have lately, it was an easy choice.  You might also want to leverage the existing Sitefinity generic content module because you do not have any development resources available to.  As the name implies it is generic, so generic in fact, it is used by the blog feature, news feature and events feature.

After a week’s worth of digging into the code and documentation, I was successful. So that you do not have to go through the pain, I will lay out the instructions for you.  This guide will require virtually no coding, just a little HTML markup and some web.config changes.

There are few steps involved with creating a new copy of the generic module.  The first step is to BACKUP your web.config file and Sitefinity project, just to be safe. Here is a list of other steps:

 Getting Started

Modify the web.config file

Create the new admin section

Create the new control templates

Add the data

Create the Sitefinity page to display the content

Summary

Document Conventions

Throughout this document you will see the text <ModuleName>. Whenever you see this text you should replace the <ModuleName> with the new name of your module. For example, I created a discount module and whenever I saw <ModuleName> I replaced it with Discount.

Getting Started

There are two bugs in Sitefinity 3.2 Service Pack 2 hot fix 1616 that cause potential problems with using multiple generic control providers and the ContentView control.  Here are the posted fixes for them.

Multiple Providers Fix

This bug does not allow for you to select multiple generic content providers.

To fix this issue, check out the Sitefinity knowledgebase article titled “Adding a custom provider for Generic Content

Setting for ContentView controls are reset fix

To fix this issue, check out the Sitefinity knowledgebase article titled “Settings applied to the Content View based controls are reset

Resource Files

Sitefinity is built on top of the .NET framework, and this coding technology can localize text properties (and other attributes, such as tooltips) Within an ASP.NET page, you will see the string <%$Resources:SearchItemsBy %>. This code tells the ASP.NET engine to get the resource file text in the key SearchItemsBy. This language is based on the page’s locale..  If this text was on the ControlPanelInsert.ascx control, ASP.NET would look within the ControlPanelInsert.ascx.resx file, unless you had localized versions then it would look in ControlPanelInsert.ascx.<locale>.resx.

For more information, please read “Walkthrough: Using Resources for Localization with ASP.NET ” from MSDN.

Keep this in mind while editing your Sitefinity controls later on.

ContentView Control Overview

The ContentView control in Sitefinity does most of the work for displaying generic content on a control or page. The ContentView control displays data on the web control by “looking” for control names that match the Meta field names within the provider.  If you have a Meta field called Product,” then the ContentView control will look for a control on the page with the name “Product” and populate the control with the value of the Meta field.

When the ContentView control sees a control with one of these names it will populate them with special functions.

Control name

Purpose

fullContent1

This will be used to create a hyperlink to the details or “SingleItem” version of this content item.

fullContent2

This is the same as fullContent1.

content

This will be used to display your generic content.

CommentsLink

This will be used to create a hyperlink to view the comments of the content

CommentsCount

This will be used to display the total number of comments on this content.

Category

This will be used to display the category of the content. If this is a hyperlink control, the contentview control, will place a hyperlink on the page that will allow you to view all of the content classified in that category.

Tags

For this you will need an ASP.NET Repeater control and the content view control will place the tags used for that content

Bookmarks

For this you will need an ASP.NET Repeater control and the content view control will place the tags used for that content

 

The ContentView control has two properties under the appearance section that tell it what control to display on the web page when you are in List mode or Single Item mode. These two properties are ItemListTemplatePath and SingleItemTemplatePath, respectively.

Modify the web.config file

Before you begin, BACKUP your web.config. The smallest error or unclosed angle bracket will cause your Sitefinity application to stop working.

Add the new provider

Locate the section in your web.cofig file that is titled cmsProvider. It looks something like this

<cmsEngine defaultProvider="Generic_Content">

Copy the element (section) whose name is “Generic_Content”. It should look something like this

<add name="Generic_Content" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="True" defaultMetaField="Name" securityProviderName="" allowLocalization="False" allowVersioning="True" allowWorkflow="False" allowComments="false" commentsModeration="true" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data"/>

Paste this element onto the next line of the web config.

Change the following attributes.

Attribute

Value

name

<ModuleName>

urlRewriteFormat

The way you would like your urls to look.

defaultMetaField

The name of the default meta field.

Note: This must match a value in the meta field that you create later; otherwise you will get a difficult to debug “The given key is not present in the dictionary” exception.

The urlRewriteFormat field can comprise of any of your Meta field names.  It my case, I created the following.

urlRewriteFormat="/[Company_Name]/[Product].aspx"

All of the other fields you are free to do with as you choose.  Her e is the sample Discount provider.

<add name="Discounts" urlRewriteFormat="/[Company_Name]/[Product].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="True" applicationName="/Discounts" defaultMetaField="Product" securityProviderName="" allowLocalization="False" allowVersioning="True" allowWorkflow="False" allowComments="false" commentsModeration="true" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data"/>

Add the new Meta fields

Further down in the web.config file, you should find a <metaFields> element, add Meta keys for each field for your new module.  For the discount module, here is what I added:

<add key="Discounts.Product" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>

<add key="Discounts.Company_Name" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>

<add key="Discounts.Company_Url" valueType="ShortText" visible="True" searchable="False" sortable="False" defaultValue=""/>

<add key="Discounts.Product_Logo_Url" valueType="ShortText" visible="True" searchable="False" sortable="True" defaultValue=""/>

<add key="Discounts.Discount" valueType="ShortText" visible="True" searchable="False" sortable="False" defaultValue=""/>

<add key="Discounts.Discount_Code" valueType="ShortText" visible="True" searchable="False" sortable="True" defaultValue=""/>

<add key="Discounts.Category" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>

<add key="Discounts.Author" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="Joseph Guadagno"/>

Please note that the name of the module and the word before the period must match the module name. For the Discounts Module provider I discussed, the name should be Discounts as shown below this sentence:

<add name="Discounts" urlRewriteFormat…>

 The important part is for each property/field you want you need to add a line. You will notice the format is <add key=”<ModuleName>.PropertyName”.  For more information on the attributes, check out the Sitefinity developer’s documentation at http://www.sitefinity.com/help/developer-manual/telerik.cms.engine-telerik.cms.engine.metainfo_members.html.

Save your web.config and this completes all necessary changes to the file.

Create your new admin section

Create the folder structure

So you can interface with the Discounts Module, you will now need to create the template files by following these steps:

  1. Open the Windows Explorer (or within Visual Studio). 
  2. Navigate to your website’s root directory.
  3. Go to ~/Sitefinity/Admin/ControlTemplates folder.
  4. Select the Generic_Content folder and paste it into the ~/Sitefinity/Admin/ControlTemplates directory.
  5. Rename that folder to <ModuleName>. In my example, I renamed it to Discounts.

File List

Old name

New Name

App_LocalResources

All of the application resource files are found here. These files contain most notably the text properties for all of the controls on the template.  There should be one .resx for each .ascx file.  This is how .NET allows you to create localized versions of your applications.

CategoriesField.ascx

Provides a drop down list of categories to choose from.

CategoriesManagement.ascx

Provides the ability to add, remove and modify categories that are available to this generic content.

CategoriesSelector.ascx

A control to select the categories to filter your records by.

CommandPanel.ascx

This control is what is displayed on the left hand side of the Sitefinity administration console.  You should not need to modify this.

CommentsEdit.ascx

A control that provides the ability to edit the comments of your generic content.

CommentsList.ascx

A control that lists the comments for your generic content.

CommentsView.ascx

A control that displays the individual comment of your generic content from the comments list control.

ContentSelector.ascx

This control provides a means to let you select generic content.

ContentVersionView.aspx

This is the control that will display the version history when you click on the version tab.

ControlPanelEdit.ascx

This is the admin control that allows you to edit your generic content.

ControlPanelInsert.ascx

This is the admin control that allows you to insert your generic content.

ControlPanelList.ascx

This is the admin control that displays the generic content available.

ControlPanelPermissions.ascx

This control provides the security controls for your generic content.

Design

Folder for the designer templates. I do not think these are used yet.

EditorTemplate.ascx

Not sure of purpose.  Not sure of use.

NewContentDialog.ascx

When you are creating page and you drag the Generic Content Module onto it, this is the dialog when you click “Share this Content”

SelectContentDialog.ascx

Same idea as above, but this is when you click on “Select Shared Content”

TagEditor.ascx

This control allows you to edit an individual tag

TagsManagement.ascx

This control allows you to edit the tags available for your content.

 

Modify the admin files

There are three files that you are going to want to modify to accommodate your new Meta fields. They are ControlPanelList.ascx, ControlPanelInsert.ascx, and ControlPanelEdit.ascx.  I listed them in the order that they should be modified for testing.

ControlPanelList.ascx

As mentioned previously, the ControlPanelList.ascx control is used to display the generic content in the admin panel. Of the three controls, the List control is the least likely to need modification. This control has two divs called “ToolsAll” and “workArea,” which break up the workspace for listing the generic content.

ToolsAll contains the createNewButton, which allows you to create a new generic content item and the searchInputs section which allows you to search for generic content. The choices for the search criteria depend on whether you make the Meta data “searchable” in the web.config file. Here is an example:

<add key="Discounts.Product" searchable="True"

The div named “workArea” is broken up into three sections; gridTitle which provides the title for the grid, the GridView1 which will display the grid of generic content items, and an ASP.NET PlaceHolder control named emptyWindow, which displays text when there are no content items in this provider.

If you would like to add a new provider with additional Meta fields, then you would need to add additional columns to GridView1 because this grid displays the meta fields.  These additional columns would help you narrow down the generic content that you want to modify. 

<asp:GridView ID="GridView1"

To add a column to the grid control looks the <Columns> element, use the sample below this sentence:

<asp:BoundField DataField="Company_Name" SortExpression="Company_Name" HeaderText="<%$Resources:Company_Name %>" HeaderStyle-CssClass="GridHeader_SiteFinity" />                           

<asp:BoundField DataField="Author" SortExpression="Author" HeaderText="<%$Resources:Author %>" HeaderStyle-CssClass="GridHeader_SiteFinity" />

 

In this sample, I removed the Description field because I am not using it. I added a Company_Name column because this was a new meta field I added to the web.config file. Be sure to remove any unused Meta data fields or else you will get a runtime exception.

ControlPanelList.ascx.resx

Here are the contents of the resource file with some modifications.

Name

Value

AllContentItems

All <ModuleName>

Author

Author

CheckGenericContentFAQ

Check <ModuleName> FAQs

Company_Name

Company name

CreateNewItem

Create a <ModuleName>

CreateYourFirstContent

Create your first <ModuleName>

CreateYourFirstContentTooltip

Click to create your <ModuleName>

Delete

Delete

Description

Description

Edit

Edit

For

for

Name

Name

NoContent

No <ModuleName> have been created yet.

Or

or

PermissionsFAQ

Permissions FAQ

Product

Product name

Search

Search

SearchItemsBy

Search <ModuleName> by

Status

Status

 

ControlPanelInsert.ascx

As mentioned previously, the ControlPanelInsert control is used to insert new generic content items for this provider.

Just like the ControlPanelList control, this control is broken up into two divs, “ToolsAll” and “divWorkArea.” The ToolsAll contains the “back to …” link and the divWorkArea contains everything else.

There are three parts to the “divWorkArea,” the sfMsg:MessageControl control which displays messages based on the success or failure of saving the content, the mainForm which provides the editing surface, and the info div, which displays the FAQ text.

The mainForm again provides the area for which you insert your generic content. Some things that you need to know.  All of the Meta data fields need to be within the control sfGCn:ContentMetaFields and the <ItemTemplate> sub element otherwise the Sitefinity engine will not save the values. The fieldset classes are used to group the content together. Here is a sample fieldset with the Meta data fields for the discount content provider.

<h3><asp:Literal runat="server" Text="<%$Resources:Discount %>"></asp:Literal></h3>

<fieldset class="set">

 <div class="setIn">

  <ol>

   <li class="author">

    <asp:Label ID="Label5" AssociatedControlID="Company_Name" runat="server">

    <asp:Literal ID="Literal7" runat="server" Text="<%$Resources:Company_Name %>"></asp:Literal>

    <em id="Em2" runat="server"></em></asp:Label>

    <asp:TextBox ID="Company_Name" Text="<%$Resources:Company_Name_Input %>" runat="server"></asp:TextBox>

   </li>

   <li class="author">

     <asp:Label ID="Label6" AssociatedControlID="Company_Url" runat="server">

     <asp:Literal ID="Literal8" runat="server" Text="<%$Resources:Company_Url %>"></asp:Literal>

     <em id="Em3" runat="server"></em></asp:Label>

     <asp:TextBox ID="Company_Url" Text="<%$Resources:Company_Url_Input %>" runat="server"></asp:TextBox>

    </li>

    <li class="author">

     <asp:Label ID="Label10" AssociatedControlID="Product_Logo_Url" runat="server">

     <asp:Literal ID="Literal12" runat="server" Text="<%$Resources:Product_Logo_Url %>"></asp:Literal>

     <em id="Em7" runat="server"></em></asp:Label>

     <asp:TextBox ID="Product_Logo_Url" Text="<%$Resources:Product_Logo_Url_Input %>" runat="server"/>

    </li>

    <li class="author">

     <asp:Label ID="Label8" AssociatedControlID="Discount" runat="server">

     <asp:Literal ID="Literal10" runat="server" Text="<%$Resources:Discount %>"></asp:Literal>

     <em id="Em5" runat="server"></em></asp:Label>

     <asp:TextBox ID="Discount" Text="<%$Resources:Discount_Input %>" runat="server"></asp:TextBox>

    </li>

    <li class="author">

     <asp:Label ID="Label9" AssociatedControlID="Discount_Code" runat="server">

     <asp:Literal ID="Literal11" runat="server" Text="<%$Resources:Discount_Code %>"></asp:Literal>

     <em id="Em6" runat="server"></em></asp:Label>

     <asp:TextBox ID="Discount_Code" Text="<%$Resources:Discount_Code_Input %>" runat="server />

    </li>

   </ol>

 </div>

</fieldset>

Each of the individual field is wrapped in a li HTML tag. There is a label, and a TextBox for each Meta data field.

In order to display the categories for your specific generic content you will need to modify the <sfCtg:CategoriesField ProviderName="<ModuleName>" ID="Category" runat="server" /> tag.  You will need to add the ProviderName attribute tag and add in the name of your generic provider.

ControlPanelInsert.ascx.resx

Here are the contents of the ControlPanelInsert.ascx.resx file for the custom module. As you will notice, I created a resource entry for each of the Meta data fields created in the web.config file.

Name

Value

AdditionalInfo

Additional Info

AdditionalInfoNote

This information is not public. It is for your reference only.

Author

Author

AuthorInput

Author...

BackToAllItems

Cancel and go back

Cancel

Cancel

Category

Category

Company_Name

Company name

Company_Name_Input

enter the company name ...

Company_Url

Company URL

Company_Url_Input

enter the company url ...

Content

Text

ContentEmpty

The text cannot be empty!

CreateThisItem

Create this discount

Description

Description

DescriptionInput

Description...

Discount

Discount

Discount_Code

Discount code

Discount_Code_Input

enter the discount code ...

Discount_Input

enter the discount ...

GenericContentFAQ

Discount FAQ

MandatoryFields

Mandatory fields

Or

or

Product

Product

Product_Empty

Product cannot be empty!

Product_Input

enter the product ...

Product_Label

Product

Product_Logo_Url

Product Url

Product_Logo_Url_Input

enter the product url ...

Save

Save

Tags

Tags

 

ControlPanelEdit.ascx

As mentioned previously, the ControlPanelEdit control is used to edit existing generic content items for this provider.  You are also redirected to this control once the insert is successful. This control will need to be edited to include controls (textboxes, dropdownlist, etc.) to edit the Meta data fields.

The ControlPanelEdit is very similar to the ControlPanelInsert except the ControlPanelEdit editing is wrapped in a radTS:RadMultiPage control. This RadMultiPage control allows you to display multiple pages or tabs on a single page by displaying one page and hiding the others.  The RadMultiPage page with the id of ViewPage displays the content and Meta data fields separately in a read-only mode. You will not need to edit this portion of the control or “page”.  The RadMultiPage page with this id of EditPage contains the editable part of the control.  This part of the control needs to be edited to add in the edit controls for each of your Meta data fields.  You will need to edit list similarly to the way the ControlPanelEdit.ascx file was updated.

In order to display the categories for your specific generic content you will need to modify the <sfCtg:CategoriesField ProviderName="<ModuleName>" ID="Category" runat="server" /> tag.  You will need to add the ProviderName attribute tag and add in the name of your generic provider.

ControlPanelEdit.ascx.resx

Here are the contents of the ControlPanelEdit.ascx.resx file for the custom module. As you will notice, I created a resource entry for each of the Meta data fields created in the web.config file.

Name

Values

AdditionalInfo

Additional info

AdditionalInfoNote

This information is not public. It is for your reference only.

Author

Author

AuthorInput

Author...

BackToAllItems

Back to all <ModuleName>

Cancel

Cancel

Category

Category

ChangeLanguage

Change Language

Company_Name

Company name

Company_Url

Company URL

Content

Text

ContentEmpty

The text cannot be empty!

Date

Date

Description

Description

DescriptionInput

Description...

Discount

Discount

Discount_Code

Discount code

Edit

Edit

EditThisItem

Edit this discount

GenericContentFAQ

Discount FAQ

History

History

IsEditingContent

is editing this <ModuleName> now!

ItemVersions

<ModuleName> Versions

MandatoryFields

Mandatory fields

Modifier

Modifier

Name

Name

NameEmpty

Name cannot be empty!

NameInput

Name...

Or

or

Product

Product

Product_Empty

Product name cannot be empty!

Product_Input

Product...

Product_Logo_Url

Product Url

Rollback

Rollback

Save

Save

SaveChanges

Save changes

Tags

Tags

Version

Version

VersionDateFormat

{0:dd MMM yyyy, hh:mm}

View

View

Create the new control templates

The control templates are used for displaying the generic content on a user facing page.

Create the folder structure

  • Open up Windows Explorer (or within Visual Studio). 
  • Navigate to where your web site files are.
  • Then navigate to ~/Sitefinity/ ControlTemplates folder.
  • Select the Generic_Content folder.
  • Copy it
  • Paste it into the~/Sitefinity/ ControlTemplates folder. Windows Explorer will give it a new name.  Rename it to <ModuleName>.
  • Copy the ~/Sitefinity/ControlTemplates/Events/SocialBookmark folder to ~/Sitefinity/ControlTemplates/<ModuleName> folder. For some reason, this was left out of the Sitefinity Generic_Content folder.

Here comes the fun part. Depending on your liking, you can rename some of the files in the ~/Sitefinity/ ControlTemplates/<ModuleName>.  Here is a list of the files that I would rename.

File List

Filename

Purpose

ArchiveTemplate.ascx

I think this is a holdover from the original News module.  We will not be using it.

CategoriesList.ascx

This is the control that will display the categories for your content.

CommentsList.ascx

This is the control that will display the comments.

ContentsViewItemList.ascx or <ModuleName>ItemList.ascx

This is the control that displays the content in a list form (multiple).

ContentsViewSingleItem.ascx or <ModuleName>SingleItem.ascx

This is the control that displays the content in a single item (details).

genericConentCommonLayout.css or

<ModuleName>CommonLayout.css

This file contains the CSS rules for this module.

socialBookmarkTemplate.xml

This contains the different social bookmarking sites available.

TagsList.ascx

This control displays all of your tag for the content.

Most of the files do not need to be modified, unless you want to.  We will concentrate on the ItemList and SingleItem files.  These files will need to be modified to display your Meta data fields.

Modify the control template files

<ModuleName>ItemList.ascx

As mentioned above in the file list section above, the ItemList control will be used to display the content items in a “repeater” or list view. As a suggestion, I would print out or keep handy the web.config section so you type the Meta data field names.

Let’s get started. If you renamed the genericConentCommonLayout.css you will need to update the FileName attribute of the sfWeb:CssFileLink element to match the new name.  It should look something link this.

<sfWeb:CssFileLink ID="CssFileLink1" FileName="~/Sitefinity/ControlTemplates/Discounts/discountsCommonLayout.css" Media="screen" runat="server" />

 

The rest of the changes pretty much come in the asp:Repeater control.  You can change the display to look how you wish. If you want to use any of the special fields like Tags or Categories, refer to the ContentView control overview earlier in this document.

<ModuleName>SingleItem.ascx

As mentioned above in the file list section above, the SingleItem control will be used to display the content item. As a suggestion, I would print out or keep handy the web.config section so you type the Meta data field names.

Let’s get started. If you renamed the genericConentCommonLayout.css you will need to update the FileName attribute of the sfWeb:CssFileLink element to match the new name.  It should look something link this.

<sfWeb:CssFileLink ID="CssFileLink1" FileName="~/Sitefinity/ControlTemplates/Discounts/discountsCommonLayout.css" Media="screen" runat="server" />

 

Everything will display within the first div.  You can change the display to look how you wish. If you want to use any of the special fields like Tags or Categories, refer to the ContentView control overview earlier in this document.

Add the data

With all of the pages saved you should be able to load the Sitefinity administration section, click on the Generic Content section to start your work.

Click the change group dropdown list and you should see the new content group available. Select the new <ModuleName> item and you will see the ControlPanelList.ascx control displayed to the right.

Click on the “Create a new content item”, the name might be different if you changed the CreateNewItem item in the ControlPanelList.ascx.resx file. You will then be displayed with the ControlPanelInsert.ascx control which will allow you to add the content.

Create the Sitefinity page to display the content

Please refer to the Sitefinity user guide section titled “Working with Web Pages” for details on how to add a page to Sitefinity.  This section will cover the ContentView control specific changes, please review to the Sitefinity use guide section “Working with user controls” for more information on adding controls to a page.  In my sample I created a page called <ModuleName>.aspx and added a ContentView control to the page, which can be found on the left hand side of the Add Controls toolbox typically in the section named Generic Content.  Once you do this click the Edit hyperlink to set the properties of the ContentView control.

Category

Property

Value

Appearance

ItemListTemplatePath

This should point to the ContentViewItemList.ascx file that you modified earlier.

Example:

~/Sitefinity/ControlTemplates/<ModuleName>/ContentViewItemList.ascx

Appearance

SingleItemListTemplatePath

This should point to the ContentViewSingleItem.ascx file that you modified earlier.

Example:

~/Sitefinity/ControlTemplates/<ModuleName>/ContentViewSingleItem.ascx

Data

ProviderName

<ModuleName>

Explicit Links

SingleItemUrl

This should point to the name of the page that the control is on.

~/<ModuleName>.aspx

Social Bookmarks

SocialBookmarkImageFolder

~/Sitefinity/ControlTemplates/<ModuleName>/SocialBookmark/

Social Bookmarks

SocialBookmarkTemplate

~/Sitefinity/ControlTemplates/<ModuleName>/socialBookmarkTemplate.xml

 

All of the other properties you can set to your liking.

Summary

As you can see, building your own generic content provider using the Sitefinity generic content module is easy.  Follow this guide and you could have your new module, like Sponsors, Products, or Books built. This should be everything that you need to get started expanding the generic content module of the Sitefinity product to meet your needs.

If there are any questions or comments, shoot me an email at jguadagno@hotmail.com.

The source can be downloaded at http://www.josephguadagno.net/documents/NewGenericContentSource.zip

This document can be downloaded at http://www.josephguadagno.net/documents/CreatingANewGenericContentModule.doc

Thanks to Joseph Anderson of Telerik for providing some helpful comments on this document.

How to create a Sitefinity custom module

 Download this document: How to create a Sitefinity custom module

Download the source: SEVDNUG.Contact.zip

This document outlines how to create a custom Sitefinity module by modifying the SEVDNUG.Contacts module.  The SEVDNUG.Contacts module was based on the Samples.Contacts module found on the Sitefinity blog.  This document gives you step by step directions on how to modify/tweak this SEVDNUG.Contacts module to implement your new custom module.  In addition, I attempt to explain what each file is used for. This sample module is constructed in a very similar to the way the modules of Sitefinity application are constructed. As a result, you should be able to use parts of this document to figure out how to customize certain features of Sitefinity modules. After completing the “First Steps” and “Modify the Code” sections of this document, your new module will be available on your Sitefinity site.

If you have any questions or issues, feel free to contact me at jguadagno [at] hotmail.com

Document conventions

 Text enclosed in <> brackets should be replaced by the type of text listed. So if you see <CompanyName>.<ModuleName>, the <ModuleName> should be replaced by whatever you want to call your module, and the <CompanyName> should be replaced by your company name like SEVDNUG.Vendors.

Contents

  • First Steps
  • Modify the Code
    • <CompanyName>.<ModuleName> Project
    • <CompanyName>.<ModuleName>.Data Project
    • <CompanyName>.<ModuleName>.Web Project
  • Sample Solution Structure          

First Steps

  • Rename the solution file to <CompanyName>.<ModuleName>.sln
  • Rename the folders
    • SEVDNUG.Contacts to <CompanyName>.<ModuleName>
    • SEVDNUG.Contacts.Data to <CompanyName>.<ModuleName>.Data
    • SEVDNUG.Contacts.Web to <CompanyName>.<ModuleName>.Web
  • Rename the Visual Studio project files
    • <CompanyName>.<ModuleName>\SEVDNUG.Contacts.csproj to <CompanyName>.<ModuleName>\<CompanyName>.<ModuleName>
    • <CompanyName>.<ModuleName>.Data\SEVDNUG.Contacts.Data.csproj to <CompanyName>.<ModuleName>.Data\<CompanyName>.<ModuleName>.Data
  • Open up the solution in a text editor like Notepad, search and replace SEVDNUG.Contacts to <CompanyName>.<ModuleName>
  • Open up the <CompanyName>.<ModuleName>.sln solution file in Visual Studio.
  • Search and replace the text  SEVDNUG.Contacts with <CompanyName>.<ModuleName>
  • Rename solution (optional)

At the end of this article you will find a sample of what the solution would like.

Modify the Code

<CompanyName>.<ModuleName> Project

Please follow these steps for this project prior to modifying the files.

  • Rename all of the Contacts*.cs files to <ModuleName>*.cs.
  • Rename IContact.cs to I<ModuleName>.cs
  • Rename WebControls\Contacts*.cs to WebControls\<ModuleName>*.cs
  • Rename WebControls\SingleContact*.cs to WebControls\Single<ModuleName>.cs
  • Rename the references to Contact object and IContact to <ModuleName>, if necessary.

I<ModuleName>.cs

  • Add whatever properties will make up the <ModuleName> object, these properties should match what you plan on storing in the database.

<ModuleName>Module.cs

This file contains the Name, Title, and Description of your module, as well as the security for your module.

  • Update the Description, Title and Name properties to whatever you want to be displayed.
  • Rename the text, Contact to <ModuleName>
  • Note that nothing else needs to be changed, other than description, title and name properties

<ModuleName>Provider.cs

This class contains the “definition” of what your module provider implementation needs to support.

  • Rename the text, Contact to <ModuleName>
  • Replace the content of the region “Contact Methods” with methods the fit your desired functionality.  Most of the contact methods should be a good starting point.
  • Add whatever additional methods you think your provider will need. Some examples are:
    • Get<ModuleName>
    • Save<ModuleName>
    • Delete<ModuleName>
    • Get<ModuleName>s
  • Under the properties section, add properties to the template files that your module will use. If you are making new templates, such as controls for the public facing side of the site such as the blog posts control, you would want to add them here. Here is an example:

 

/// <summary>

/// Returns the path of external template for ControlPanel control in insert/edit mode

/// </summary>

public string ControlPanelInsertEditTemplate

        {

            get

            {

                return this.controlPanelInsertEditTemplate;

            }

        }

<ModuleName>Manager.cs

This class provides is present in most Provider model patterns. It contain methods to interact with the provider.

  • Rename the text, Contact to <ModuleName>
  • Replace the content of the region “Contact Methods” with methods the fit your desired functionality.  Most of the contact methods should be a good starting point. This should closely mirror the Provider methods.
  • Add whatever additional methods you think your manager class will need.

WebControls/*

These classes provide the functionality to edit or display the data within Sitefinity.

  • Replace the text, Contact to <ModuleName>
  • Note, you probably will have to manually change the Resources/Messages.resx content. TODO: Add reference to new localization article.

Single<ModuleName>.cs

This is used to display a single item (<ModuleName>). This file provides the code behind to the Single<ModuleName>.ascx file.

  • Replace the text, Contact to <ModuleName>
  • Modify the Single<ModuleName>Container to include the fields defined in I<ModuleName>.cs file.
  • Modify the CreateChildControls to reflect the controls that are available in the layoutContainer

<ModuleName>Lists.cs

This is used to display a list of items (<ModuleName>s)

  • Replace the text, Contact to <ModuleName>
  • Modify the <ModuleName>Repeater_ItemDataBound method to display the properties of the object.

Admin\<ModuleName>Editor.cs

This control is used for inserting new <ModuleName> objects or editing existing ones.

  • Replace the text, Contact to <ModuleName>
  • Update the CreateChildControls method of the <ModuleName>Editor class to match the properties available within your new module class.
  • Update the CreateNew<ModuleName> method of the <ModuleName>Editor class to match the properties available within your new module class.
  • Update the Update<ModuleName> method of the <ModuleName>Editor class to match the properties available within your new module class.
  • Update the <ModuleName>EditorContainer class to the match the properties within your new module class. This should most likely match the Single<ModuleName>.cs class.

Essentially, any properties that are available in your I<ModuleName> interface should have a line in the CreateChildControls, CreateNew<ModuleName>, Update<ModuleName> methods, as wells as properties in the <ModuleName>EditorContainer class.

Admin\CommandPanel.cs

This module is used to display the side content in the Sitefinity admin interface. Other than changing its name, you do not need to change this control.

  • Replace the text, Contact to <ModuleName>

Admin\ControlPanel.cs

This module is used to display the side content in the Sitefinity admin interface. Other than changing its name, you do not need to change this control.

  • Replace the text, Contact to <ModuleName>

<CompanyName>.<ModuleName>.Data Project

This assembly is responsible for all of the data access. At minimum it will have three classes, with this implementation, DefaultProvider.cs, Variable.dbclass, and <ModuleName>.dbclass. Optionally, you can add <ModuleName>.cs and <ModuleNames>s.cs to add additional data access methods. Any file with the extension “.dbclass” makes a table in your database.

Please follow these steps for this project prior to modifying the files.

  • Rename Contact.* to <ModuleName>*.cs
  • Search and replace Contact with <ModuleName>.
  • Add a reference to the new <CompanyName>.<ModuleName> project.

DefaultProvider.cs

This class provides the implementation of the provider for the <ModuleName>. The private fields and following methods should not need to be changed; SetVariable, GetVariable, and Initialize. The first step to do is to replace the Contact with <ModuleName>. The next step is to implement any of the other methods required by <ModuleName>Provider.

Variable.dbclass

This file generates the database table for the variables table. This should not change.

<ModuleName>.dbclass

This class generates the database for the <ModuleName> table.  This file should change according to the way you want your database table. The Nolics library will create the table for you. Example:

dbclass ModuleName [TableName="SEVDNUG_ModuleName"]{

    primary key string Application [50], guid ID[AutoGenGUID = true];

    string Name[Length=100];

    string Url[Length=255];

    string LogoUrl[Length=255];

    modified date ModifiedOn;

    created date CreatedOn;

For more info on modifying the dbclass library or how to modify this file, check the Nolics documentation at http://www.nolics.net/Docs4_2/Ref_dbclass.html.

Where is the tutorial that tells you how to make tables?

<ModuleName>.cs

This class will allow you to add additional properties and methods to the Nolics generated class.

<ModuleName>s.cs

This class creates a dynamic query around the module table. Dynamic queries are typically used when there are custom table joins that you want to be available to any calling class. For more information on creating or using dynamic queries with Nolics please check out the Nolics documentation at http://www.nolics.com/Material2005/WT10_Queries.doc.

public class ModuleNames: Query<ModuleName>

{

 

}

<CompanyName>.<ModuleName>.Web Project

Please follow these steps for this project prior to modifying the files.

  • Rename the /Sitefinity/ControlTemplates/Contacts folder to /Sitefinity/ControlTemplates/<ModuleName>
  • Rename the file /Sitefinity/ControlTemplates/<ModuleName>/ContactsListTemplate.ascx to <ModuleName>ListTemplate.ascx
  • Rename the file /Sitefinity/ControlTemplates/<ModuleName>/ContactsListTemplate.ascx to Single<ModuleName>Template.ascx

Web.Config

The web.config file for your Sitefinity installation will need to be modified to inform Sitefinity of the new module.  Please note: this section of the document requires that you modify your existing Sitefinity web.config. PLEASE BACK UP YOU WEB.CONFIG FILE BEFORE YOU CHANGE IT.

There are three parts of the web.config file that need to be modified. They include the modules section, section group, and the meta fields section. The web.config provided in this example has a <!-- START REPLACE : Step # --> tag followed by a <!— END REPLACE : Step # --> tag where text needs to be replaced or modified. 

Notify ASP.NET of the new section group

Search for <!-- START REPLACE : Step 1 -->.  This section needs to be placed after the closing tag of the Telerik section group of your existing Sitefinity web.config file.

  • Replace the text of SEVDNUG with your company name. This should be what every use used for <CompanyName>.
  • Replace the text of Contacts with your module name. This should be what every use used for <ModuleName>.

Tell Sitefinity about your new module

Search for <!-- START REPLACE : Step 2 -->.  The line following this tag needs to be added to you telerik/framework/modules/ section of your existing Sitefinity web.config file.

  • Replace the text of SEVDNUG with your company name. This should be what every use used for <CompanyName>.
  • Replace the text of Contacts with your module name. This should be what every use used for <ModuleName>.

 

Add the new section group

Search <!-- START REPLACE : Step 3 -->.  Everything between this tag and the <!-- END REPLACE : Step 3 --> tag should be added to the end your exist web.config.

  • Replace the text of SEVDNUG with your company name. This should be what every use used for <CompanyName>.
  • Replace the text of Contacts with your module name. This should be what every use used for <ModuleName>.
  • Replace the text of contact with the <ModuleName> for the following lines.

contactsPermissionsTemplate="~/Sitefinity/Admin/ControlTemplates/Contacts/ContactsPermissionsTemplate.ascx"

contactEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Contacts/ContactEditorTemplate.ascx"

contactsListTemplate="~/Sitefinity/ControlTemplates/Contacts/ContactsListTemplate.ascx"

singleContactTemplate="~/Sitefinity/ControlTemplates/Contacts/SingleContactTemplate.ascx"

Note, these xml attributes map to the properties that you defined in the <ModuleName>Provider class. Here is an example:

/// <summary>

/// Returns the path of external template for ContactsPermission

/// view set in web.config

/// </summary>

public string ContactsPermissionsTemplate

{

get

{

                return this.contactsPermissionsTemplate;

            }

        }

Add the new meta fields

So Sitefinity can recognize the database columns that your module will make, you must declare them in the meta fields section of your web.config. Here is an example from the blogs module:

<metafields>

<add key="<ModuleName>.Title" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>

<add key="<ModuleName>.Author" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>

<add key="<ModuleName>.Publication_Date" valueType="DateTime" visible="True" searchable="True" sortable="True" defaultValue="#Now"/>

<add key="<ModuleName>.BlogID" valueType="Guid" visible="False" searchable="True" sortable="True" defaultValue=""/>

<add key="<ModuleName>.Category" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""></add>

</metafields>

Here is a breakdown of the properties:

Key: This is the name of your module, then a period, then the name of the field.

ValueType: This property will depend on the type you set in your I<ModuleName>.cs file. If you set the type to GUID, then the value type will be GUID. This property should be short text for a paragraph under 256 characters and long text if it is above 256 characters.

Visible: This property should be true, unless this field is an ID column which should not be edited. If the valueType property is GUID, then the visible property should be false.

Searchable: If you would like your end user to search this property in the admin when in this module, then set this property to true. In the blogs module, as an example, you can search blogs by title.

Sortable: In the grid for the module in the admin, this will make the field sortable.

DefaultValue: This property is set to null, unless you want a value to be added all the time

Public and Private Templates

So your end user can use the control on the page, you will need a public template. Generally, this consists of a repeater control with a series of controls inheriting from the ItextControl Interface. Sitefinity mainly uses literal and label controls and binds their ID property to a datafield. In the blogs module, you could bind a label control to the autor field like this:

<asp:Label ID=”Author” runat=”server”></asp:label>

When you are in the blogs module, you omit the word blogs and just use the word after the period.

The private templates are for users who click on the modules tab in the admin. These templates are used to add content to the modules and set permissions. Generally, you would only want to edit the templates that a person uses to add content. Adding and removing fields in the same as the public templates. Just add a label, as an example, and give its ID property a name from the meta fields section of the web.config.

Copy to Sitefinity

To deploy your module, you must copy the module theme, the newly created bin files and the templates by following these instructions:

  • Add a reference in your Sitefinity web project to the new <CompanyName>.<ModuleName> and <CompanyName>.<ModuleName>.Data assemblies or projects.
  • Copy <CompanyName>.<ModuleName>.Website\Admin\ControlTemplates\<ModuleName> to your Sitefinity directory\Admin\ControlTemplates\<ModuleName>
  • Copy <CompanyName>.<ModuleName>.Website\ControlTemplates\<ModuleName> to your Sitefinity directory\ ControlTemplates\<ModuleName>
  • Copy <CompanyName>.<ModuleName>.Website\Admin\Themes\Default\ to your Sitefinity directory\Admin\Themes\Default\

Sample Solution Structure

<CompanyName>.<ModuleName>

·         Properties

o   AssemblyInfo.cs

·         References

o   RadComboNox.Net2 [i]

o   RadGrid.Net2[ii]

o   RadMenu.Net2[iii]

o   RadTreeView.Net2 [iv]

o   System

o   System.configuration

o   System.Data

o   System.Drawing

o   System.Web

o   System.Xml

o   Telerik.Cms

o   Telerik.Cms.Web.UI

o   Telerik.Framework

o   Telerik.Security

·         Configuration

o   ConfigurationHelper.cs

o   SectionHandler.cs

·         Resources

o   CommandPanel.js

o   Messages.resx

·         Security

o   GlobalPermission.cs

o   GlobalPermissions.cs

·         WebControls

o   Admin

§  AlphabetLinks.cs [v]

§  CommandPanel.cs

§  <ModuleName>Editor.cs

§  ControlPanel.cs

o   <ModuleName>List.cs

o   <ModuleName>ListToolboxItem.cs

o   Single<ModuleName>.cs

o   Single<ModuleName>ToolboxItem.cs

·         <ModuleName>Manager.cs

·         <ModuleName>.Module.cs

·         <ModuleName>Provider.cs

·         I<ModuleName>.cs

<CompanyName>.<ModuleName>.Data

·         Properties

o   AssemblyInfo.cs

·         References

o   Nolics.Engine.v4.2 [vi]

o   <CompanyName>.<ModuleName>

o   System

o   System.configuration

o   System.Data

o   System.Xml

o   Telerik.DataAccess

o   Telerik.Framework

o   Telerik.Security

·         Resources

o   Messages.resx

·         <ModuleName>.cs  [vii]

·         <TableName>.dbclass

·         DefaultProvider.cs

<CompanyName>.<ModuleName>.Website

·         Admin

o   ControlTemplates

§  <ModuleName>

·         CommandPanelTemplate.ascx

·         <ModuleName>EditorTemplate.ascx

·         <ModuleName>sPermissions.ascx

·         ControlPanelInsertEditTemplate.ascx

·         ControlPanelListTemplate.ascx

o   App_LocalResources

§  Any resource files

o   Themes

§  Default

·         Modules.css

·         ControlTemplates

o   <ModuleName>

§  <ModuleName>sListTemplate.ascx

§  Single<ModuleName>Template.ascx



[i] Optional, only required if you controls/templates use this control and you are licensed to use it.

[ii] Optional, only required if you controls/templates use this control and you are licensed to use it.

[iii] Optional, only required if you controls/templates use this control and you are licensed to use it.

[iv] Optional, only required if you controls/templates use this control and you are licensed to use it.

[v] Optional, only if you wish to implement this command panel control.

[vi] Optional, only if you use the Nolics library for data access.

[vii] Optional, only if you want to add additional data access methods to the Nolics’ generated class.

Telerik.Events

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:

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.

string providerName = "Events";
EventsManager eventsManager = new Telerik.Events.EventsManager(providerName);

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...
    EventsManager eventsManager = new Telerik.Events.EventsManager(providerName);
  • Create a new generic content object...
    IContent newEvent = eventsManager.Content.CreateContent("text/html");
  • Update the meta data...
    newEvent.SetMetaData("Title", eventTitle);
    newEvent.SetMetaData("Content", eventDescription);
  • Optionally, get/create an event category, then update the meta data...
    // If the categoryName is not null or empty, update the category field.
    if (string.IsNullOrEmpty(categoryName) == false)
    {
        // See if this event category exists
        ICategory category = eventsManager.Content.GetCategory(categoryName);
        if (category == null)
        {
            // Create the category            
            category = eventsManager.Content.CreateCategory(categoryName);
            eventsManager.Content.SaveCategory(category);
        }
        // Update the meta data
        newEvent.SetMetaData("Category", categoryName);
    }
  • Save the content...
    eventsManager.Content.SaveContent(newEvent);

Utility method for creating an event.

    protected void CreateEvent(
        string eventTitle, 
        string eventDescription,
        string contactName,
        string contactEmail,
        string contactPhone,
        string contactCell,
        string contactWeb,
        string street,
        string city,
        string state,
        string country,
        DateTime eventStartDate, 
        DateTime eventEndDate,
        DateTime eventExpirationDate,
        DateTime publicationDate,
        string geomappingData,
        string categoryName,
    {

        string providerName = "Events";
        EventsManager eventsManager = new Telerik.Events.EventsManager(providerName);
        IContent newEvent = eventsManager.Content.CreateContent("text/html");
        
        // Set the Generic Content Meta Data
        newEvent.SetMetaData("Title", eventTitle);
        newEvent.SetMetaData("Content", eventDescription);
        newEvent.SetMetaData("Street", street);
        newEvent.SetMetaData("City", city);
        newEvent.SetMetaData("State", state);
        newEvent.SetMetaData("Country", country);
        newEvent.SetMetaData("Contact_Name", contactName);
        newEvent.SetMetaData("Contact_Email", contactEmail);
        newEvent.SetMetaData("Contact_Phone", contactPhone);
        newEvent.SetMetaData("Contact_Cell", contactCell);
        newEvent.SetMetaData("Contact_Web", contactWeb);

        newEvent.SetMetaData("Event_Start", eventStartDate);
        newEvent.SetMetaData("Event_End", eventEndDate);
        newEvent.SetMetaData("Publication_Date", publicationDate);
        newEvent.SetMetaData("Expiration_Date", eventExpirationDate);
        newEvent.SetMetaData("Geomapping_Data", geomappingData);

        // If the categoryName is not null or empty, update the category field.
        if (string.IsNullOrEmpty(categoryName) == false)
        {
            // See if this event category exists
            ICategory category = eventsManager.Content.GetCategory(categoryName);
            if (category == null)
            {
                // Create the category
                category = eventsManager.Content.CreateCategory(categoryName);
                eventsManager.Content.SaveCategory(category);
            }
            // Update the meta data
            newEvent.SetMetaData("Category", categoryName);
        }

        // Save the Generic content
        eventsManager.Content.SaveContent(newEvent);

    }

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 boolen which indicates if the manager should delete the associated generic content.

public void DeleteEvent(Guid ID, bool deleteContentItem)

The second overload requires two parameters, the Event which is the Event.Id and a boolen which indicates if the manager should delete the associated generic content.

public void DeleteEvent(IEvent _event, bool deleteContentItem);

Warning: This sample will delete all of the events in Sitefinity.

string providerName = "Events";
EventsManager eventsManager = new Telerik.Events.EventsManager(providerName);

IList events = eventsManager.GetEvents();
foreach (IEvent eventItem in events)
{
    eventsManager.DeleteEvent(eventItem.ID, true);
}

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:
  • Binary
  • Boolean
  • DateTime
  • FloatingPoint
  • Guid
  • Integer
  • LongText
  • ShortText
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

<add key="Events.ClickToAttendId" valueType="ShortText" visible="True" searchable="False" sortable="True" defaultValue=""/>

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...

    </ItemTemplate>
</sfGCn:ContentMetaFields>

An example of the markup could look like this.

    
<h3><asp:Literal ID="ltrClickToAttend" runat="server" Text="<%$Resources:ClickToAttend %>"></asp:Literal></h3>
<fieldset class="set">
    <div class="setIn">
        <asp:Label ID="lblClickToAttendId" runat="server" Text='<%$Resources:ClickToAttendId %>' AssociatedControlID="ClickToAttendId"></asp:Label>
        <asp:TextBox ID="ClickToAttendId" runat="server"></asp:TextBox>
    </div>
</fieldset>
<div class="bottom">
    <div>
        <!-- -->
    </div>
</div>

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.

    <h4>Event Registration</h4>
<p>This event requires registration, please register <a href='http://www.clicktoattend.com/invitation.aspx?code=<asp:Literal ID="ClickToAttendId" runat="server"></asp:Literal>'>here</a>.</p>

Just as in the administrative templates, in order to display the meta data there should be a control on the form that matches the name of the meta data.
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.

<asp:PlaceHolder ID="plClickToAttendId" runat="server">
    <h2>Event Registration</h2>
    <p>Please click
        <asp:HyperLink ID="ClickToAttendId" runat="server" NavigateUrl='<% "http://www.clicktoattend.com/invitation.aspx?code=" + this.Text %>'></asp:HyperLink>
        to complete the registration for this event.</p>
</asp:PlaceHolder>

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...