[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]
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.
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
<sf:ContentCategoriesField ID="Category" runat="server" /> |
<%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls.Admin" Assembly="Telerik.Cms.Engine" %> |
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" /> |
<%@ Register TagPrefix="sf" Namespace="Telerik.Cms.Engine.WebControls.Admin" Assembly="Telerik.Cms.Engine" %> |
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: