Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

Can't seem to figure this one out. Trying to display a custom "thread closed" phrase if the thread is within specific nodes.

Code:
<xf:macro name="thread_status" arg-thread="!" arg-wrapperClass="">
    <xf:if contentcheck="true">
        <div class="{$wrapperClass}">
            <dl class="blockStatus">
                <dt>{{ phrase('status') }}</dt>
                <xf:contentcheck>
                    <xf:if is="$thread.discussion_state == 'deleted'">
                        <dd class="blockStatus-message blockStatus-message--deleted">
                            <xf:macro template="deletion_macros" name="notice" arg-log="{$thread.DeletionLog}" />
                        </dd>
                    <xf:elseif is="$thread.discussion_state == 'moderated'" />
                        <dd class="blockStatus-message blockStatus-message--moderated">
                            {{ phrase('awaiting_approval_before_being_displayed_publicly') }}
                        </dd>
                    </xf:if>
                    <xf:if is="!$thread.discussion_open">
                        <xf:if is="{{ in_array($forum.Node.parent_node_id, ['20','55']) }}">
                            <dd class="blockStatus-message blockStatus-message--locked">
                                {{ phrase('custom_thread_closed') }}
                            </dd>
                        <xf:else />    
                            <dd class="blockStatus-message blockStatus-message--locked">
                                {{ phrase('not_open_for_further_replies') }}
                            </dd>
                        </xf:if>    
                    </xf:if>
                </xf:contentcheck>
            </dl>
        </div>
    </xf:if>
</xf:macro>

If I use just this portion outside of the rest of it, it works as intended.

Code:
                    <xf:if is="!$thread.discussion_open">
                        <xf:if is="{{ in_array($forum.Node.parent_node_id, ['20','55']) }}">
                            <dd class="blockStatus-message blockStatus-message--locked">
                                {{ phrase('custom_thread_closed') }}
                            </dd>
                        <xf:else />    
                            <dd class="blockStatus-message blockStatus-message--locked">
                                {{ phrase('not_open_for_further_replies') }}
                            </dd>
                        </xf:if>    
                    </xf:if>
 
How can I hide a custom field from a thread to certain user groups ?

I tried to place the code directly in the creator of custom fields but it has no effect.
 
I'm trying to post an image at the top of a node in the forum_list view. By using this:

Code:
<xf:if is="$forum.node_id == 58">
    Show content..
</xf:if>

But nothing is showing up.

forum_list
Code:
<xf:macro template="{$nodeTemplate.template}" name="{$nodeTemplate.macro}"
            arg-node="{$node}"
            arg-extras="{$extras}"
            arg-children="{$children}"
            arg-childExtras="{$childExtras}"
            arg-depth="{$depth}" />
                    <xf:if is="$forum.node_id == 58">
               Show content..
</xf:if>
    <xf:elseif is="{$nodeTemplate.template}" />
        <xf:include template="{$nodeTemplate.template}" />
    </xf:if>
</xf:macro>
 
Anyone know how to use more than one conditional? i.e !$xf.visitor.user_id and $xf.visitor.isAwaitingEmailConfirmation() ... Ideally I want it added to the display condition box on the edit widget page.

Edit: This worked: !$xf.visitor.user_id OR $xf.visitor.isAwaitingEmailConfirmation()
 
Need this working in a Widget, but it wont work for me.o_O
Code:
<xf:if is="!in_array($__globals.forum.node_id, [5,6,7,8])">
 
Last edited:
Need this working in a Widget, but it wont work for me.o_O
Code:
<xf:if is="!in_array($__globals.forum.node_id, [5,6,7,8])">

I'm having the same issue.

Can't get the widget to show only in particular specified NODES thru the widget interface.

I've tried...

$forum.node_id == 84
<xf:if is="$forum.node_id == 84">

and a variety of other "throw doo-doo on the wall" attempts.

Nothing seems to work.

203757
 
Need this working in a Widget, but it wont work for me.o_O
Code:
<xf:if is="!in_array($__globals.forum.node_id, [5,6,7,8])">
What about
Code:
<xf:if is="!in_array($forum.node_id, [5,6,7,8])">
This code will not display widget in node_id 5 6 7 8.
I think you should add arg-forum="{$forum}" when you call thread_list_macros in widget template.
 
This does not work in the widget either.
But I found another solution.
<xf:if is="!$xf.visitor.is_admin OR !$xf.visitor.is_moderator">

The WidgetCode (GoogleSearch) should not be running private forums (privacy) where moderators and admins discuss.
This solution helped me because he achieved the same. :D
 
Top Bottom