Message board count

Sathish Kannan asked on March 29, 2016 16:34


I'm new to Kentico, I'm using BlogPost and Message board in the same page where BlogPost displays the blog heading with number of comments submitted, I'm using message board for comments. Now, is it possible to get the total number of approved messages in BlogPost transformation?Image Text

Correct Answer

Trevor Fayas answered on March 29, 2016 17:23

Sathish, the 2nd part of my response should be able to do what you want to, although i'm sorry i gave Blog Comments instead of Message Board. Use the text/xml transformation and the macro

{% Queries["board.message.selectall"].Where("MessageApproved = 1").Count |(user)zbynekh|(hash)7eb67fdd9865bd08772ec197d8d6074661347dd97328b20bd70dc8286d2095f1%}

You may need to add additional Where logic to get it to where you want.

If you need to use ASCX transformation, you can create a custom Transformation Helper that can use Kentico's DataEngine.QueryInfoProvider class to do similar.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Trevor Fayas answered on March 29, 2016 16:55 (last edited on March 24, 2018 12:15)

Anything is possible!

If you are repeating out the BlogPosts, and you just need a "count" of how many items are in your repeater, you can use the <%# DataItemCount %> or {% DataItemCount %} (depending on what transformation type). This gives the number of items being transformed.

Otherwise Kentico is database driven, which means you can easily create a query that will get that count, and reference it.

For simplicity sake, you may want to leverage the Text/xml transformation type (so you can use kentico macros), then use the following macro:

{% Queries["blog.comment.selectall"].Where("CommentApproved = 1").Count |(user)zbynekh|(hash)64da27c1d77947a3fa19c06c0b7cd0577beb026417356b22a6141628e2f48165%}

I couldn't really test the above but that should do the trick.

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on March 29, 2016 17:15 (last edited on March 29, 2016 17:17)

Thanks for your reply.

Well, this could be helpful if I use blogpost comments but I'm using messageboard and my question is how to get message board messages count.

So I need to retrieve the total number of messages approved in message board. And I want to use this count inside blog post transformation.


0 votesVote for this answer Mark as a Correct answer

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