XF 2.0 Adding class to thread item based on node ID and thread count

Case

Well-known member
Trying to add a class to an existing div in the thread_list_macros template by using {{ $forum.node_id == 34 AND $thread.reply_count > 1 ? 'extra-class' : '' }}

The node_id part isn't working though. Is this possible?
 

Chris D

XenForo developer
Staff member
The thread_list_macros template and item macro is called in a few places -- where are you testing this condition? In most places, the $forum arg is passed in so it should be available.

Does this work any better?
Code:
{{ ($forum.node_id == 34 AND $thread.reply_count > 1) ? 'extra-class' : '' }}
 

Chris D

XenForo developer
Staff member
FWIW you'd probably might as well switch $forum.node_id with $thread.node_id. The node_id value is always available on the thread entity and the thread arg is always passed into this macro. However, there are some lists of threads where we don't pass the $forum arg in.
 

Case

Well-known member
FWIW you'd probably might as well switch $forum.node_id with $thread.node_id. The node_id value is always available on the thread entity and the thread arg is always passed into this macro. However, there are some lists of threads where we don't pass the $forum arg in.
I seem to be getting server errors with this code now.

Code:
ErrorException: Template error: Illegal string offset 'node_id'
internal_data/code_cache/templates/l1/s24/public/thread_list_macros.php:302
Did something change?
 
Top