1. 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?

Discussion in 'Styling and Customization Questions' started by Stuart Wright, Jan 15, 2014.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    Hi folks,
    so we have
    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).
  2. Stuart Wright

    Stuart Wright Well-Known Member

    Silly me, I found the answer. It's simple and I must have misstyped it first time:
    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.
  3. Mike

    Mike XenForo Developer Staff Member

    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.
  4. Stuart Wright

    Stuart Wright Well-Known Member

    Lol yes.
    <xen:if is="{$block.reply_count}>0">s</xen:if>
    Not my original code :)
    Last edited: Jan 16, 2014

Share This Page