XF 2.1 Condition in_array in a template

SyTry

Well-known member
Hello,

I want to update my add-on with 2 new options :
  • Excluded forums
  • Excluded usergroups
This one :

So, my problem is the condition.
For forum : !in_array($thread.node_id, $xf.options.sc_ltvfc_excluded_forums)
For usergroup : !in_array($xf.visitor.user_group_id, $xf.options.sc_ltvfc_excluded_usergroups)

Here is my full code :
Code:
<xf:if is="!in_array($thread.node_id, $xf.options.sc_ltvfc_excluded_forums) AND !in_array($xf.visitor.user_group_id, $xf.options.sc_ltvfc_excluded_usergroups) AND $post.isFirstPost()">
    <xf:set var="$snippetPost" value="{{ snippet($post.message, {$xf.options.lgnCharacters}) }}" />
    {{  bb_code($snippetPost, 'post', $post)  }}
    <xf:if is="$snippetPost != $post.message">
        <div style="padding-top:1em;">
            <div class="blockMessage {$xf.options.lgnNotice} blockMessage--iconic">
                {{ phrase('sytry_Login_View_Content') }} <a href="{{ link('login') }}" data-xf-click="overlay">{{ phrase('log_in_or_register_now') }}</a>
            </div>
        </div>
    </xf:if>
    <xf:else/>
    {{ bb_code($post.message, 'post', $post) }}
</xf:if>

But I have a problem, here is my options :
203175

Results :
  • Main forum + Registered : Can't view
  • Second forum + Registered : Can't view
It shoud be this :
  • Main forum + Registered : Can view
  • Second forum + Registered : Can't view
Note :
If you have an idea, thank you ! :D

Regards, SyTry
 

Masetrix

Well-known member
change $thread.node_id to $__globals.thread.node_id or $__globals.forum.node_id or
$thread.thread_id ?
 
Top