XF 2.2 Template - Respect Custom Field Visibility

Foxtrek_64

Active member
Hi all, I'm using the following template code in the thread_list_macros template. The intent is that, in designated forums, certain tickets should show as either "unclaimed" or "claimed" with information on who has claimed it.


HTML:
<xf:if is="$thread.custom_fields.ticketOwner">
    <div class="structItem-minor">
        <xf:if is="$xf.visitor.username == $thread.custom_fields.ticketOwner">
            {{ phrase('application_claimed_by') }}: <div class="application-claimOwn">{$thread.custom_fields.ticketOwner}</span>
        <xf:else />
            {{ phrase('application_claimed_by') }}: {$thread.custom_fields.ticketOwner}
        </xf:if>
    </div>
    <xf:else />
    <div class="structItem-minor">
        <div class="application-unclaimed">{{ phrase('application_unclaimed') }}</span>
    </div>
</xf:if>

This code works perfectly in those selected forums. The problem is that it also works in all forums, even in those where it is not appropriate.

What is the best way to modify this so that this modification only appears in the forums configured by the "applicable forums" field in the custom thread field configuration?

Edit: A general code review is also appreciated.
 
Last edited:
Solution
Hi all, I'm using the following template code in the thread_list_macros template. The intent is that, in designated forums, certain tickets should show as either "unclaimed" or "claimed" with information on who has claimed it.


HTML:
<xf:if is="$thread.custom_fields.ticketOwner">
    <div class="structItem-minor">
        <xf:if is="$xf.visitor.username == $thread.custom_fields.ticketOwner">
            {{ phrase('application_claimed_by') }}: <div class="application-claimOwn">{$thread.custom_fields.ticketOwner}</span>
        <xf:else />
            {{ phrase('application_claimed_by') }}: {$thread.custom_fields.ticketOwner}
        </xf:if>
    </div>
    <xf:else />
    <div class="structItem-minor">
        <div...
Hi all, I'm using the following template code in the thread_list_macros template. The intent is that, in designated forums, certain tickets should show as either "unclaimed" or "claimed" with information on who has claimed it.


HTML:
<xf:if is="$thread.custom_fields.ticketOwner">
    <div class="structItem-minor">
        <xf:if is="$xf.visitor.username == $thread.custom_fields.ticketOwner">
            {{ phrase('application_claimed_by') }}: <div class="application-claimOwn">{$thread.custom_fields.ticketOwner}</span>
        <xf:else />
            {{ phrase('application_claimed_by') }}: {$thread.custom_fields.ticketOwner}
        </xf:if>
    </div>
    <xf:else />
    <div class="structItem-minor">
        <div class="application-unclaimed">{{ phrase('application_unclaimed') }}</span>
    </div>
</xf:if>

This code works perfectly in those selected forums. The problem is that it also works in all forums, even in those where it is not appropriate.

What is the best way to modify this so that this modification only appears in the forums configured by the "applicable forums" field in the custom thread field configuration?
If I understand your question you need to restrict to certain nodes. Wrap your code in:
Code:
<xf:if is="in_array({$forum.node_id}, [X,Y,Z])">
                  Show content..
</xf:if>
 
Solution
Back
Top Bottom