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

Admin Template xf:if explanation

Discussion in 'XenForo Development Discussions' started by silence, Dec 2, 2013.

  1. silence

    silence Well-Known Member

    In the ban edit admin template, there is this snippit:
    HTML:
            <xen:snippet>
                {xen:if {$bannedUser.user_reason}, '{xen:phrase reason}: <span class="muted">{$bannedUser.user_reason}</span>'}
                {xen:phrase ban_ends}: <span class="muted">{xen:if $bannedUser.end_date, {xen:datetime $bannedUser.end_date}, '{xen:phrase never}'}</span>
            </xen:snippet>
    In the line here:
    HTML:
    {xen:if $bannedUser.end_date, {xen:datetime $bannedUser.end_date}, '{xen:phrase never}'}
    I'm extremely confused as to how that exactly works. Is it checking if $bannedUser.end_date is true?
    Could someone be generous enough to explain that, I feel dumb :(
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    If there is an end date, show the formatted date, else display the phrase never.
     
  3. silence

    silence Well-Known Member

    Ah gotcha. I feel sorta dumb. Does it check if it's 0, false, null or just a single value?
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    It works the same as the PHP if function.
     
  5. silence

    silence Well-Known Member

    Yeah but those commas threw me off :oops:
    Well I got it now so thanks :)
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    Syntax:

    Code:
    {xen:if (boolean expression), (true), (false)}
    Translates to:

    Code:
    if (boolean expression) {
     (true)
    } else {
     (false)
    }
     
    silence and Chris D like this.

Share This Page