Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

#41
How can I combine

Code:
<xf:if is="$template == 'thread_view'">
   Show content..
</xf:if>

<xf:if is="$template =='forum_view'">
   Show content..
</xf:if>
into one condition?
 

Andy.N

Well-known member
#44
How do I show User Upgrade (id=3) only to members who already purchased user upgrade (id=2) or belong to usergroup ID =10?
 
#48
I'm trying to show who is the Thread starter.

I've attempted with this conditional but seems that doesn't work:

{$post.user_id} == {$thread.User}

and

{$post.user_id} == {$thread.user_id}

Any help would be really appreciated.

In XF1 I used this: {$post.user_id} == {$thread.user_id} and worked very well.
 

hqarrse

Active member
#49
Any chance you could help me with the conditional to display content after thread x on a page (i.e in the forum_view/forum_macros templates)?

Many thanks
 
#53
Hello

I need an issue if the poster is in user group x.
Like this:
Code:
<xf:if is="{{$xf.user.isMemberOf(x)}}">
Show content...
</xf:if>
Even better something like this:
Code:
<xf:if is="in_array({$user}.isMemberOf [X,Y,Z])">
    Show content..
</xf:if>
But it does not work that way.
In the post_macros Template.
How is it correct?
 
#54
I was using this code in XenForo 1 to hide the Post based on the prefix:

<xen:if is="{xen:helper threadPrefix, $thread, plain, ""} != '+HD' AND {xen:helper ismemberof, $visitor, 1, 2} OR {xen:helper ismemberof, $visitor, 3, 4, 6, 7, 8}">

Content

<xen:else />

<p class="importantMessage">{xen:phrase hd_user}</p>

</xen:if>


The red code is the code used in xF1 to hide the content between this two. And the blue code is the hide content.

How can I adapt it to XenForo 2?


Thanks.
 
Last edited:
#57
I have to adapt this but I don't know this: "{xen:helper threadPrefix, $thread, plain, ""} != '+HD'

The "plain" text give an error in the xF2...
 
Last edited:

DL6

Well-known member
#59
I was using this code in XenForo 1 to hide the Post based on the prefix:

<xen:if is="{xen:helper threadPrefix, $thread, plain, ""} != '+HD' AND {xen:helper ismemberof, $visitor, 1, 2} OR {xen:helper ismemberof, $visitor, 3, 4, 6, 7, 8}">

Content

<xen:else />

<p class="importantMessage">{xen:phrase hd_user}</p>

</xen:if>


The red code is the code used in xF1 to hide the content between this two. And the blue code is the hide content.

How can I adapt it to XenForo 2?


Thanks.
Code:
<xf:if is="prefix_title('thread', $thread.prefix_id) == '+HD' AND $xf.visitor.isMemberOf([1,2]) OR $xf.visitor.isMemberOf([3,4,6,7,8])">

Content

<xf:else />

<p class="importantMessage">{{ phrase('hd_user') }}</p>

</xf:if>
 
#60
Code:
<xf:if is="prefix_title('thread', $thread.prefix_id) == '+HD' AND $xf.visitor.isMemberOf([1,2]) OR $xf.visitor.isMemberOf([3,4,6,7,8])">

Content

<xf:else />

<p class="importantMessage">{{ phrase('hd_user') }}</p>

</xf:if>
Thank you very much!. This was what I was looking for!
 
Top