• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 How do I use xen:calc and xen:number together in a template?

Stuart Wright

Well-known member
#1
Hi folks,
so we have
Code:
title="{xen:calc '{$block.reply_count}+1'} Comment<xen:if is="{xen:calc '{$block.reply_count}+1'}!=1">s</xen:if>"
that number is occasionally more than 1,000 and I want to use xen:number on it to format the number properly with a comma.
How do I use both please? (I tried a few combinations which gave template save errors).
 

Stuart Wright

Well-known member
#2
Silly me, I found the answer. It's simple and I must have misstyped it first time:
Code:
title="{xen:number {xen:calc '{$block.reply_count}+1'}}} Comment<xen:if is="{xen:calc '{$block.reply_count}+1'}!=1">s</xen:if>"
I think I missed an ending squiggly bracket.
Anyway, hopefully useful for those people who are searching for the same answer.
 

Mike

XenForo developer
Staff member
#3
BTW, in your if tag, you don't even need the calculation - subtract 1 from each size. You're just checking if there if reply_count != 0.