Run query through web part

Sathish Kannan asked on June 1, 2016 16:30

I just want to run a query through web part to check the documents count for each menu. Here is my scenario,

When user clicks on image, he will be navigated to sub page which displays the documents related to the clicked one.

What I need to do is, if there is no documents available, I need to hide the image.

Hide if no records is not going to work here. Any other solution to reach this

Recent Answers


Laura Frese answered on June 1, 2016 18:15

You can write a custom query that will return the documents and the count. In your transformation, add the count to the html tag as a data-item or something, then you can use javascript to hide the image if the count is 0.

https://docs.kentico.com/display/K8/Loading+data+using+custom+queries

select count(*) as Count, ##COLUMNS## from CMS_Documents where ##WHERE## Order by ##ORDERBY##

0 votesVote for this answer Mark as a Correct answer

Sathish Kannan answered on June 1, 2016 18:26

Thanks much!

This helps me to get entire count. Is it possible to get counts in document name specific.

For example, I have 10 documents under Malaysian food menus and 30 documents under Chinese food menus.,

So, when I write custom query in my transformation, it should give me the count in specific to document name.

I tried, but it was not working. And ideas pls

0 votesVote for this answer Mark as a Correct answer

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