When use Kentico for a Blog with Comments, it has the following fields:
But I want to use the current authenticated user's name, and don't need the E-mail or Your URL options.
On one-off pages, we can use CSS to set the fields to display:none
by their HTML IDs, but that won't work for Blogs because the IDs will change often since they are generated by ASP.NET based on the control tree.
Is there a way to hide these fields by configuring the BlogComments web part (we can't find any settings in there for them), or do we have to replace the BlogComments web part with custom code?
UPDATE: Looks like you can't do this without customizing code (see accepted answer below), at least in v5.5 R2 and older; maybe not in v6 either? Vote for the feature suggestion to add it at to a future version of Kentico in this Kentico UserVoice request.
We looked into the web part code, and Kentico 5.5 does not offer the ability to customize them via web part properties, nor even with a custom web part since the blog module doesn't even offer it. So we did this:
~/CMSModules/Blogs/Controls/BlogCommentView.ascx
and ~/CMSModules/Blogs/Controls/BlogCommentEdit.ascx
and renamed them...View.ascx
to reference the new ...Edit.ascx
...Edit.ascx
's @Register Src="..."
attribute to point to the new ...Edit.ascx
style="display:none"
on the <tr>
rows that we just wanted to use the defaults. (This site required authentication already, so the user's name was already filled into the Name field, and the E-mail and URL fields aren't used in our case so it didn't matter what was in them since we didn't require the E-mail field per the Blog settings.)...View.ascx
:The new Layout code that just changed the Src
attribute in the @Register
element:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/CMSWebParts/Blogs/BlogCommentView.ascx.cs" Inherits="CMSWebParts_Blogs_BlogCommentView" %>
<%@ Register Src="~/CustomBlogCommentView.ascx" TagName="BlogCommentView" TagPrefix="cms" %>
<cms:BlogCommentView ID="commentView" runat="server" />