I need to setup an {if} statement that will show “1 Comment” when there is only one comment. If there are multiple comments, the title should have an “S” on the end with the title being “2 Comments”.
Is that possible? Not sure how to do it…
Thanks!
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
December 08, 2009 2:34pm
Subscribe [3]#1 / Dec 08, 2009 2:34pm
I need to setup an {if} statement that will show “1 Comment” when there is only one comment. If there are multiple comments, the title should have an “S” on the end with the title being “2 Comments”.
Is that possible? Not sure how to do it…
Thanks!
#2 / Dec 08, 2009 4:10pm
Have you tried something like this between your {exp:comment:entries} tags?
<h5>{count} COMMENT{if count >1}S{/if}</h5>You could probably also test for count!= “0” and selectively display the comment counter or an alternate message like “Be the first to Comment about this Entry!”
#3 / Dec 08, 2009 4:39pm
Thanks Bob! That works great, but it also removes the “s” when there are no comments. I need it to be “0 Comments” instead of “0 Comment”. I tried modifying the if statement, but not luck…
#4 / Dec 08, 2009 4:43pm
{count} comment{if count != 1}s{/if}😊
#5 / Dec 08, 2009 4:49pm
Ahhh… I figured out why it wasn’t working. I was trying to use “count”, but this case called for “comment_total”.
Comment{if comment_total != 1}s{/if}
#6 / Dec 08, 2009 4:50pm
I don’t have time to run this in a live page that has comments, but it oughta work:
<h5>{count} COMMENT{if count == 0 OR if count >1}S{/if}</h5>#7 / Dec 08, 2009 4:51pm
Thanks Bob & Ingmar… Problem solved.
#8 / Dec 08, 2009 4:57pm
You’re right. COUNT is the sequence where the Comment occurs in a Comment list for an entry. e.g. “This is Comment No. {count}.” My bad.