function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael Benson 4Michael Benson 4 

Knowledge Article How to Count Articles Displayed?

I have a VisualForce page using only the standard apex markup  <Knowledge:ArticleList>.

How can you know how many articles will be displayed?

How can you know if it returned no articles at all?

Visualforce Page:
<apex:page >
    <!-- User Guides Content section-->
User Guides
<knowledge:articleList articleVar="article" categories="Knowledge_Categories:AccuDate_9700" keyword="warranty" articleTypes="KB_Article__kav" pageSize="10">
<li>
<apex:outputLink target="_self" value="{!URLFOR($Action.KnowledgeArticle.View, article.id, ['popup' = 'true'])}">{!article.title}</apex:outputLink>
</li>
</knowledge:articleList> 
<!-- User Guides Content section-->    
    
</apex:page>

 
Best Answer chosen by Michael Benson 4
Shashikant SharmaShashikant Sharma
Hi Michael,

You could use apex:variable and count it first
 
<apex:page >
    <!-- User Guides Content section-->
User Guides
<apex:variable var="c" value="{!0}" />
<knowledge:articleList articleVar="article" categories="Knowledge_Categories:AccuDate_9700" keyword="warranty" articleTypes="KB_Article__kav" pageSize="10">

 <apex:variable var="c" value="{!(c + 1)}" />
</knowledge:articleList> 

<p>Count : {!c} </p>


<knowledge:articleList articleVar="article" categories="Knowledge_Categories:AccuDate_9700" keyword="warranty" articleTypes="KB_Article__kav" pageSize="10">
<li>
<apex:outputLink target="_self" value="{!URLFOR($Action.KnowledgeArticle.View, article.id, ['popup' = 'true'])}">{!article.title}</apex:outputLink>
</li>
</knowledge:articleList> 
<!-- User Guides Content section-->    
    
</apex:page>

Let me know if it helps or you still face issues.


Thanks
Shashikant

All Answers

Shashikant SharmaShashikant Sharma
Hi Michael,

You could use apex:variable and count it first
 
<apex:page >
    <!-- User Guides Content section-->
User Guides
<apex:variable var="c" value="{!0}" />
<knowledge:articleList articleVar="article" categories="Knowledge_Categories:AccuDate_9700" keyword="warranty" articleTypes="KB_Article__kav" pageSize="10">

 <apex:variable var="c" value="{!(c + 1)}" />
</knowledge:articleList> 

<p>Count : {!c} </p>


<knowledge:articleList articleVar="article" categories="Knowledge_Categories:AccuDate_9700" keyword="warranty" articleTypes="KB_Article__kav" pageSize="10">
<li>
<apex:outputLink target="_self" value="{!URLFOR($Action.KnowledgeArticle.View, article.id, ['popup' = 'true'])}">{!article.title}</apex:outputLink>
</li>
</knowledge:articleList> 
<!-- User Guides Content section-->    
    
</apex:page>

Let me know if it helps or you still face issues.


Thanks
Shashikant
This was selected as the best answer
Michael Benson 4Michael Benson 4
Thank you so much. That is exactly what I needed. So simple, I was over thinking it.  

Appreciate your Help.

Michael

 
Shashikant SharmaShashikant Sharma
Glad that I could help you :).

Thanks
Shashikant