Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

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

What do you want to do by doing this? Because it's a bit irrational.
 
How do I show User Upgrade (id=3) only to members who already purchased user upgrade (id=2) or belong to usergroup ID =10?
 
I need to show banner ads on only the thread_view and forum_view pages.

maybe something like this?...not tried it.

PHP:
<xf:if is="$template == 'thread_view' OR $template == 'forum_view'">
   Show content for both?..
</xf:if>
 
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.
 
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
 
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.

Has anybody got a solution for this?
 
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?
 
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:
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:
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>
 
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 Bottom