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

annet rose answered on April 19, 2018 07:19

Limiting number of comments is necessary for the article because this will definitely help you to protect from spammers. Unlimited commenting option will definitely affect the quality of your blog and i think you have got the correct solution from this site too.Babylon tours louvre tickets online

0 votesVote for this answer Mark as a Correct answer

aadil khan answered on May 9, 2018 12:00

Hello friend this is a wonderful place and nice website the great information here click this link homepage i have agreed this website is very nice just use the my homepage thanks for sharing it.

0 votesVote for this answer Mark as a Correct answer

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