XF 2.1 Apply custom class to threads in certain sections based on usergroup (conditional help)

Joe Link

Well-known member
Trying to apply a custom class to threads in nodes with parent categories defined in the options. Using this to apply the class via JS and it's working.

Code:
{{ in_array($forum.Node.parent_node_id, [$xf.options.link_gen_opt_class_cat1, $xf.options.link_gen_opt_class_cat2]) }}

What I need to do is combine that conditional with this one in the thread_list_macro template to assign the customClass to structItem.

Code:
{{$thread.User.isMemberOf('3') ? ' customClass' : ''}}

I want to put this combined conditional here. If I put either of those conditionals in there they work, I'm just having trouble combining them (syntax issue I'm sure). I've tried multiple iterations of both AND and && and neither seem to work.

Code:
<div class="structItem structItem--thread{{ $thread.discussion_open ? '' : ' is-locked' }}{{ $thread.prefix_id ? ' is-prefix' . $thread.prefix_id : '' }}{{ $thread.isIgnored() ? ' is-ignored' : '' }}{{ ($thread.isUnread() AND !$forceRead) ? ' is-unread' : '' }}{{ $thread.discussion_state == 'moderated' ? ' is-moderated' : '' }}{{ $thread.discussion_state == 'deleted' ? ' is-deleted' : '' }}<COMBINED CONDITIONAL HERE> js-inlineModContainer js-threadListItem-{$thread.thread_id}" data-author="{{ $thread.User.username ?: $thread.username }}" >
 
I think I got it! (only took me 7 hours).

I had to wrap the whole thing in ()'s

Code:
($thread.User.isMemberOf('3') AND in_array($forum.Node.parent_node_id, [$xf.options.link_gen_opt_class_cat1, $xf.options.link_gen_opt_class_cat2]))
 
Top Bottom