Hide Blog Comments Web Part When Comments are Turned Off

Scott Hancock asked on April 28, 2016 21:58

Some of our blogs have comments turned off. If comments are turned off, I'd like to hide the text "0 Comments" in the blog transformations but I can't find a macro function to do it. Has anyone done this?

Recent Answers


Brian McKeiver answered on April 28, 2016 22:48 (last edited on April 28, 2016 23:25)

Look for this line in your transformation:

<%# BlogFunctions.GetBlogCommentsCount(Eval("DocumentID"),Eval("NodeAliasPath")) %> comments

If you have not made anything custom, it would be CMS.BlogPost.Default


Sorry I re-read your question and realized you are probably looking for how to react to having comments disabled on the actual CMS.Blog page. Assuming your NodeAliasPath to the blog is at "/Blog" it would be some boolean check that looks at the BlogOpenCommentsFor property.

Documents["/Blog"].BlogOpenCommentsFor == 0

0 == Disabled

-1 == Always

N == number of days comments are allowed for.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.