XF 2.1 Widget display condition

BassMan

Well-known member
If I enter in widget display position for example $forum.node_id == 270 to show this widget only in specific forum it does not work.

But if I add this to forum_view template it works:
Code:
<xf:if is="$forum.node_id == 270">
    <xf:widget key="test" position="sidebar" />
</xf:if>

What am I missing here?
 
When you put that in a template, you have all of the data available to the template directly accessible. When you attach to a particular location, you only have specific context available (or the global vars). The context available is location specific. If you're attaching to global positions, you're unlikely to have much within the context.

To see all of the data available to a particular location, you can create an HTML widget and attach it to the location you want, with this content:
Code:
{{ dump(vars()) }}
This will show you the data that is available to the widget.

If you're attaching to a global position, you may want to look at the {$xf.reply.containerKey} value
 
This will show you the data that is available to the widget.
To expand on this, it would appear that although those vars() are available inside the widget, they are not all available to use in the Widget "Display Conditions".

Sorry, to bring this one up again.

I cannot figure out, how to show a widget only on one forum, using the widget display position.
Try this, where '123' is the forum ID you want to target:

Code:
$xf.reply.containerKey == 'node-123'
 
Back
Top Bottom