Sitefinity in its current version comes with two built-in settings: TextSetting and ContentSetting. In the previous post I’ve explained the TextSetting control and in this one we will expore ContentSetting.
Why have different setting controls?
Before I dig into the details, the first question that ought to be answered is why use different settings. The answer is quite simple: they control their targets in different manner. TextSetting is the most rudimentary setting which controls the visibility, label and format of its target control. ContentSetting is a bit more advanced setting, which generally (though its not a rule) controls a target which displays a full content of generic content item (news, post, event…).
How do I add ContentSetting to the designer?
Adding a ContentSetting to the designer is no different than adding the TextSetting. You simply have to open the designer template and declare the control inside of the Master od Detail settings collection of the given presentation mode. If you wish to see an example of this, you can open the following file in your Sitefinity installation:
and scroll down to the MasterSettings collection od the ModeSettings1 control. You will find ContentSetting control there declared as follows:
|<sfDesignSettings:ContentSetting id="ContentSetting1" |
| TargetID="content"> |
As you can see ContentSetting control needs only two properties to be set:
- ID – not important, only needs to be unique in the designer template
- TargetID – id of the control that setting is controlling
How does ContentSetting look in the designer?
In the previous post, we’ve seen that the appearance of the TextSetting control largely depends on the value of its properties. ContentSetting control, on the other hand, always looks the same. Take a look at Figure 1 to see how can you recognize a ContentSetting control in your designer.
Figure 1: Two modes of ContentSetting control
What is the purpose of the ContentSetting control?
Admittedly, this section should have been closer to the beginning of the post, but better late than never. ContentSetting control has a purpose of dynamic creation of summaries. Let’s imagine that we want to display a list of blog posts. By implementing a ContentSetting control on the “content” or “post” target control, which is bound to the full text of the post, we can easily open the designer and switch to the summary mode where we can define how do we want the summary to be created. We can limit the number of words that we want to display, as well as perform html stripping. In case we want to display the full post with all HTML, we can just switch back to the content mode.
Now that we have covered the two built in settings, in the next post, we’ll do something more exciting. We are going to create our own custom setting control. Then in the posts to follow, we’ll explore presentation modes and how to extend those and for the grand finale - we are going to build a whole custom content view designer.
If you have any questions or suggestions, please leave a comment.