More in this section
Blogs RSS feed

Products module: Insert / Edit templates control guidance

by User Not Found

[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]

When you develop Generic Content based modules, you will surely have at least two Views that deal with content items - one View for creating new content items and one View for editing existing content items. If you are going to build new Views from scratch, it is generally irrelevant which controls will you use to provide user interface for creating new or editing existing content items.


If, however, you are going to reuse the base Views (ContentItemNew and ContentItemEdit), there are few things to note.

Content editing control

By default Generic Content uses Telerik RadEditor control for editing content. The control must have the id attribute set to “Editor”. The control for editing content looks like the one on the screenshot below:


You are free to use a different control for editing content as long as this control implements IEditableTextControl interface and has the id set to “Editor”. For example, we could replace the instance of RadEditor with TextBox.

Meta field input controls

Sitefinity provides an automatic way of saving and setting the values of meta field controls. For example, in our sample products module we have a control which user can use to set the price of the product, but we did not need to implement any code for it to work. Sitefinity will save the value of this control and also set the value of it in the edit mode. In order to achieve this, following conditions must be met:
  • Control for editing meta field value must have the same ID as the key of the meta field. For example, if we have “Products.Price” meta field defined in the web.config, our control will have the id “Price” (Products or the word before the dot is the name of the provider, while the meta field key is the word after the dot).
  • Control must implement ITextControl interface, which mandates the control to have Text property. It is text property that Sitefinity will read when saving the values or set when setting the values. Many controls, such as TextBox and DropDownList implement ITextControl interface. If you need a more complex control for editing the value of the metafield, you can create a new user control (or composite control) and implement ITextControl interface on it. Sitefinity will save any value that you provide it with in the Text property.
  • Control must be placed in the ItemTemplate of the ContentMetaFields control.
An example of the controls for editing the value of the meta fields can be seen on the screenshot below:

So, as you can see, while there are some rules that must be followed - the implementation is very flexible and imposes no serious restrictions.

Category control

Generic Content modules support categorization of the content as a built-in feature. In Sitefinity 3.6 this feature has been extended to support hierarchical categories as well. In your templates for creating or editing content items, you can provide at most one control for setting the category to which the content belongs to. When implementing this control, there are two rules to be followed:
  • Id of the control must be set to “Category”
  • Control must implement IContentCategoriesField interface
Sitefinity comes with a built-in control for setting the category which is called ContentCategoriesField and you can use it in your template as follows:
<sf:ContentCategoriesField ID="Category" runat="server" /> 
If you will be using this control, do not forget to register the control by having the following line at the top of your template:
<%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls.Admin" Assembly="Telerik.Cms.Engine" %> 
You are, obviously, free to provide your own implementation of the control for setting the category as long as you met the two given rules. The default implementation of the ContentCategoriesField control looks like the one on the screenshot below:


Tags control

Similarly to the categories, a specialized control is needed for tagging the content. As with anything in Sitefinity, you are free to provide your own implementation of this control as long as you satisfy two following rules:
  • Id of the control must be set to “tagsControl”
  • The control must implement IContentTagEditor interface

Sitefinity comes with a built-in control for tagging content which you can use in your template in following manner:

<sf:ContentTagEditor ID="tagsControl" runat="server" /> 
If you will be using this control, do not forget to register the control by having the following line at the top of your template:
<%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls.Admin" Assembly="Telerik.Cms.Engine" %> 
If you are to implement your own tag editor control, bear in mind that it is responsibility of the tag editor control to tag the content and persist it to the storage. In other words, Sitefinity will provide you only with the provider name and id of the content, from which point on it is your responsibility to tag the content through the Generic Content API.


The built in ContentTagEditor control is a very responsive control which takes advantage of the client side code and looks like the one on the screenshot below:




Leave a comment
  1. Romi Mar 24, 2009
    Hi Ivan,
    Nice work. Could you explain how to add some server action to CreateNew button, delete and edit buttons in ListMode. These items are now as hyperlinks before as buttons. We can't use onclick event. Regards 
  2. Ivan Mar 24, 2009
    Hi Romi,

    you can change hyperlinks to buttons and then have them make postback. In the event handler you can use NavigateHostCommand to change the View as explained in this article:

    While this will work, we do not advise it unless necessary. Let me know what kind of server functionality you are looking to hook up to CreateNew button and I'll try to give you a more concrete advice.
  3. LED Lights Aug 10, 2013
    The Condé Nast Cafeteria at 4 Times Square, New York, has luminous walls and ceilings. The LED bulbs behind these surfaces create an ever-changing and colourful light display.

    Leave a comment