How to Customize Blogs
Hello Everyone,
I want to customize the fields of Blogs for Comments,I am having an sitefinity4.2 Application including an Login Control Page to Login the registered User, I want only to Use 'Name(Optional)', and the 'Loggedin UserId' Field during Posting the Comments and also to send an Email notification to the Admin about the Comment Posted. Please Provide a demo code to do that..
Thanks,
Ankit Rastogi
Hi Ankit,
To achieve this you should map a template for comments implementing a logic that will take the username and fill the textbox. Here is the template for CommentsDetailsVeiw
<%@ Control Language="C#" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" TagPrefix="sf" %><%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %><%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %> <asp:Panel ID="authenticatedUserContainer" runat="server" CssClass="sfcommentsFormWrp"> <asp:Panel ID="moderationContainer" runat="server" Visible="false"> <p class="sfNeutral"> <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:ContentResources, CommentMessageModeration %>" /> </p> </asp:Panel> <h2 class="sfcommentsTitle"><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:ContentResources, Comment%>" /></h2> <fieldset class="sfcommentsForm"> <ol class="sfcommentsFieldsList"> <li id="authorNameControlWrapper" runat="server" class="sfcommentsField"> <sf:TextField ID="authorName" runat="server" DisplayMode ="Write" Title="<%$Resources:ContentResources, YourName%>"> CommentsDetailsView <ValidatorDefinition Required="true" RequiredViolationMessage="<%$Resources:ContentResources, NameCannotBeEmpty %>" MessageCssClass="sfError" /> </sf:TextField> </li> <li id="emailControlWrapper" runat="server" class="sfcommentsField"> <sf:TextField ID="email" runat="server" DisplayMode ="Write" Title="<%$Resources:ContentResources, EmailOptional %>"> <ValidatorDefinition RequiredViolationMessage="<%$Resources:ContentResources, EmailCannotBeEmpty %>" ExpectedFormat="EmailAddress" Required="false" MessageCssClass="sfError" /> </sf:TextField> </li> <li id="websiteControlWrapper" runat="server" class="sfcommentsField"> <sf:TextField ID="website" runat="server" DisplayMode ="Write" Title="<%$Resources:ContentResources, WebsiteOptional%>"> <ValidatorDefinition RequiredViolationMessage= "<%$Resources:ContentResources, WebSiteCannotBeEmpty %>" ExpectedFormat="InternetUrl" Required="false" MessageCssClass="sfError" /> </sf:TextField> </li> <li id="contentControlWrapper" runat="server" class="sfcommentEditor sfcommentsField"> <sf:HtmlField ID="content" runat="server" DisplayMode="Write" EditorToolsConfiguration="Minimal" HtmlFieldEditModes="Design" Title="<%$Resources:ContentResources, Comment%>" EditorContentFilters="DefaultFilters" EditorStripFormattingOptions="AllExceptNewLines" Height="200" IsToOverrideDialogs="false"> <ValidatorDefinition RequiredViolationMessage="<%$Resources:ContentResources, CommentCannotBeEmpty %>" Required="true" MessageCssClass="sfError" /> </sf:HtmlField> </li> <li id="captchaWrapper" runat="server" class="sfcommentsField sfcommentCaptcha"> <telerik:RadCaptcha ID="captcha" runat="server" ErrorMessage="<%$Resources:ContentResources, PageNotValid %>" Display="Dynamic" Skin="Sitefinity" /> </li> </ol> <div class="sfcommentsSubmitBtnWrp"> <asp:Button ID="submitBtn" runat="server" Text="<%$Resources:ContentResources, Submit%>" CommandName="submitComment" CausesValidation="true" class="sfcommentsSubmitBtn" /> </div> </fieldset></asp:Panel><asp:Panel ID="anonymousUserContainer" runat="server" Visible="false"> <p> <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:ContentResources, PostingCommentsIsNotAllowed %>" /> </p></asp:Panel>protected override string LayoutTemplateName get return null; public override string LayoutTemplatePath get return Test.layoutTemplate; private const string layoutTemplate = "~/VppPrefix/SitefinityWebApp.MasterView.Comments.ascx"; EmailSender.Get().TrySend(new MailMessage(new MailAddress("mail address"), new MailAddress("mail address")));Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>