Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

Am I missing something? It displays the 0, and 1 comment, but not multiple comments.

I'm sure it's a simple answer, but I can't see what error I'm making, and I'm not getting any feedback in developer mode.

I'm using default comments with EE, and i'm using version 2.9.2.

Thanks!

{if {total_results} == 0}<h4>0 Comments</h4>
{if:elseif {total_results} == 1}<h4>{total_results} Comment</h4>     
{if:elseif {total_results} > 1}<h4>{total_results} Comments</h4>{/if}
share|improve this question

2 Answers 2

Try these two variations:

{if total_results == 0}<h4>0 Comments</h4>
{if:elseif total_results == 1}<h4>{total_results} Comment</h4>     
{if:elseif total_results > 1}<h4>{total_results} Comments</h4>{/if}

or:

{if "{total_results}" == 0}<h4>0 Comments</h4>
{if:elseif "{total_results}" == 1}<h4>{total_results} Comment</h4>     
{if:elseif "{total_results}" > 1}<h4>{total_results} Comments</h4>{/if}

The template parser can get really wonky sometimes, and doesn't parse everything in the correct order.

share|improve this answer
    
Unfortunately, I'm still getting the same results. I suspected it might be parse order, but I hoped a simple if else wouldn't cause any problems. –  unsider Jul 7 at 15:36

Can you try something like this:

<h4>
{total_results} Comment{if total_results == "0" OR total_results > "1"}s{/if}
</h4>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.