XF 2.2 Widget condition (array) not working

jb-net

Active member
Hi,

I'm using the latest version XF 2.2.10 and I want to display a sidebar widget in the thread view only if a thread is part of some particular forums.

Therefore, I set the widget condition to:

in_array($xf.reply.containerKey,['node-10‘,’node-11’,’node-13’,’node-16’,’node-85’,’node-115’])

But the condition is ignored and the widget is display in any forum, even those not part of the array?

Any idea what I'm doing wrong?

Thanks!
 

Attachments

  • Bildschirmfoto 2022-09-05 um 06.50.51.webp
    Bildschirmfoto 2022-09-05 um 06.50.51.webp
    93.6 KB · Views: 4
Solution
Code:
in_array($xf.reply.containerKey,['node-10‘,’node-11’,’node-13’,’node-16’,’node-85’,’node-115’])
You are using , not ' - this won't work as the condition is unparsable so XenForo silently ignores it.

Code:
in_array($xf.reply.containerKey, ['node-10', 'node-11', 'node-13', 'node-16', 'node-85', 'node-115'])
does work.

But I'd prefer
Code:
in_array($context.thread.node_id, [10, 11, 13, 16, 85, 115])
as this is the "intended" way to check for thins like specific nodes.
Code:
in_array($xf.reply.containerKey,['node-10‘,’node-11’,’node-13’,’node-16’,’node-85’,’node-115’])
You are using , not ' - this won't work as the condition is unparsable so XenForo silently ignores it.

Code:
in_array($xf.reply.containerKey, ['node-10', 'node-11', 'node-13', 'node-16', 'node-85', 'node-115'])
does work.

But I'd prefer
Code:
in_array($context.thread.node_id, [10, 11, 13, 16, 85, 115])
as this is the "intended" way to check for thins like specific nodes.
 
Last edited:
Solution
But I'd prefer
Code:
in_array($context.thread.node_id, [10, 11, 13, 16, 85, 115])
as this is the "intended" way to check for thins like specific nodes.
This code does not work for me.

This is the code i use to display a widget in specific node (forum_view).
Code:
in_array($xf.reply.containerKey, ['node-225','node-235', 'node-215', 'node-206', 'node-217', 'node-210', 'node-226', 'node-209', 'node-199', 'node-221', 'node-207', 'node-214', 'node-224', 'node-220', 'node-228'])

If i use your syntax
Code:
in_array($context.thread.node_id, [225, 235, 215, 206, 217, 210, 226, 209, 199, 221, 207, 214, 224, 220, 228])
The widget is never displayed.
 
This code does not work for me.

This is the code i use to display a widget in specific node (forum_view).
@jb-net asked for widgets to be displayed on thread_view sidebar if the thread is in specific nodes.

This condition does exactly that, it does not work for forum_view (or any other location that does not have a thread context)
 
Last edited:
Back
Top Bottom