The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
Each ContentView based control represents content items that have been created from the backend or programmatically. The ContentView based control has two modes
Build-in ContentView based controls are - EventsView, BlogPosts, NewsView, ContentView control, ImageGalley, DownloadList. The last two controls are ContentView based, but they have different presentation modes, because they are supposed to show data from Images and Documents module.
For each ContentView control you can enable comments. Enabling comments can be done through the control's Advanced/Properties tab where you will find Comments section. Once you have enabled the comments you may need to protect the form from online spammers. By default, SpamProtection is not enabled on Sitefinity comment. There is no public property that you can use to do this. Since 3.6 Sitefinity uses embedded templates, so first you need to map external template - ListPageDetails.ascx, then you need to find the SpamPropector declaration at the bottom of the template and enable SpamProtector control. You can save all these steps by creating a simple control that inherits from one of the ContentView based control and expose an user friendly public property. Then you only have to use this control instead of the built-in and set the custom property from the control designer.
1. Create a custom control that inherits from BlogPosts( or another ContentView based control).
2. Override SingleItemTemplatePath and ItemListTemplatePath properties where you need to set the path to external templates that the control will use in List and Details mode.
3. Create a ViewState property of Boolean type (true/false) that you will use in the control designer. You can set Category and Description of this property, so that you can find it easily under Advanced/Properties tab. All properties that do not have Category set are added under Misc section.
4. Crete a control references to RadEditor and SpamPropector controls. You can find the controls from the control's SingleContainer.
5. Override CreateSingleContent method, set the RadEditor as visible and check the value of the custom property - ShowCaptcha.
public
class
BlogPostsCustomControl : BlogPosts
{
public
BlogPostsCustomControl()
{
}
public
override
string
SingleItemTemplatePath
{
get
{
return
"~/Sitefinity/Admin/ControlTemplates/Blogs/Modes/ListPageDetail.ascx"
;
}
}
public
override
string
ItemListTemplatePath
{
get
{
return
"~/Sitefinity/Admin/ControlTemplates/Blogs/Modes/ListPageMaster.ascx"
;
}
}
public
virtual
bool
ShowCaptcha
{
get
{
object
obj = ViewState[
"ShowCaptcha"
];
if
(obj !=
null
)
return
(
bool
)obj;
return
true
;
}
set
{
ViewState[
"ShowCaptcha"
] = value;
}
}
protected
override
void
CreateSingleContent()
{
base
.CreateSingleContent();
Editor.Visible =
true
;
if
(ShowCaptcha)
{
Captcha.EnableCaptcha =
true
;
Captcha.Visible =
true
;
}
else
{
Captcha.Visible =
false
;
}
}
protected
virtual
SpamProtector Captcha
{
get
{
return
((Telerik.Web.UI.SpamProtection.SpamProtector)((Telerik.Blogs.WebControls.BlogCommentsList)(
this
.SingleContainer.CommentsListCtrl)).Controls[0].FindControl(
"spamProtector"
));
}
}
protected
virtual
RadEditor Editor
{
get
{
return
((Telerik.Blogs.WebControls.BlogCommentsList)(
this
.SingleContainer.CommentsListCtrl)).Controls[0].FindControl(
"commentTxt"
)
as
RadEditor;
}
}
}
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.