Display Comments number

Tonka Penkova asked on April 7, 2015 16:28

Hi, I need to display the number of comments that an article has. Does anyone has an idea how this can happen? Thank you!

Correct Answer

Katrina Miday answered on April 7, 2015 18:12

Do you mean the number of comments on a blog post, or the number of comments in a message board attached to an article page?

If it's for the number of messages on a message board, I'm currently using the following to display the number of comments within a preview transformation for news items. It should probably also work for articles, given you customize the code for your environment and database.

This is included in the selected columns:

(SELECT COUNT(*) FROM intranet.dbo.Board_Message WHERE Board_Message.MessageBoardID IN (SELECT BoardID FROM intranet.dbo.Board_Board WHERE BoardDocumentID = DocumentID)) AS CommentCount

and this is in the transformation to display the number:

<a href='<%# GetDocumentUrl() + "#comments" %>'><%# Eval("CommentCount") %> Comments</a>

If you're asking for comments on a blog post:

<a href="<%# GetDocumentUrl() %>#comments"><%# BlogFunctions.GetBlogCommentsCount(Eval("DocumentID"), Eval("NodeAliasPath")) %> comments</a>
1 votesVote for this answer Unmark Correct answer

Recent Answers


Tonka Penkova answered on April 8, 2015 15:35

Thank you, Katrina !

With few changes it worked :)

0 votesVote for this answer Mark as a Correct answer

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