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

Multiple conditions in xenforo template syntax

CyberAP

Well-known member
#1
Is it possible to make such a condition as that?
PHP:
<xen:if is="@showTwitter" || "@showFacebook" || "@showYouTube">
Some content
<xen:else>
Other content
</xen:if>
 

Kier

XenForo Developer
Staff member
#2
You can do that like this:
HTML:
<xen:if is="@showTwitter || @showFacebook || @showYouTube">
	Some content
<xen:else />
	Other content
</xen:if>
However, you may also be interested in 'has content':
HTML:
<xen:if hascontent="true">
	<div class="sectionMain">
		<p>This will only show if there is something in
			the content check:</p>
		<xen:contentcheck>
			<xen:if is="@showTwitter">Twitter stuff</xen:if>
			<xen:if is="@showFacebook">Facebook stuff</xen:if>
			<xen:if is="@showYouTube">YouTube stuff</xen:if>
		</xen:contentcheck>
	</div>
<xen:else />
	<p>There was nothing to show.</p>
</xen:if>
 
#4
The following always evaluates to true, though I cannot see why...

Code:
                    <xen:if hascontent="true">
                        <dt>{xen:helper userFieldTitle, musicStyle}:</dt>
                        <xen:contentcheck>                    
                            <dd>{xen:helper userFieldValue, $userFieldsInfo.musicStyle, $user, {$user.customFields.musicStyle}}</dd>
                        </xen:contentcheck>
                    <xen:else />
                        <dt>{xen:helper userFieldTitle, musicStyle}:</dt><dd>Unknown</dd>
                    </xen:if>
 

Valhalla

Well-known member
#5
Most likely because of the <dd> tags. It will always evaluate to true because they are always present, unlike your custom user field, which may not have been set.

Code:
<xen:if hascontent="true">
     <dt>{xen:helper userFieldTitle, musicStyle}:</dt>
     <dd>
          <xen:contentcheck>
               {xen:helper userFieldValue, $userFieldsInfo.musicStyle, $user, {$user.customFields.musicStyle}}
          </xen:contentcheck>
     </dd>
<xen:else />
     <dt>{xen:helper userFieldTitle, musicStyle}:</dt>
     <dd>Unknown</dd>
</xen:if>
 
Last edited:
#6
Most likely because of the <dd> tags. It will always evaluate to true because they are always present, unlike your custom user field, which may not have been set.
I've since removed them and it still evaluates to true... you should note too that there are no <dd> tags inside the xen:contentcheck area, which is where it looks to find anything.