XF 2.0 Conditionals for widgets

Mr Lucky

Well-known member
Licensed customer
Is there a way to apply conditional statements to widgets, e.g. to show a widget to only a specific user or user group?

Thanks

If not, is there a way to include a widget in a notice?
 
Our recommendation is to create the desired widget instance with no positions selected, then create a new HTML widget. You can then use conditionals directly in that wrapped around a call to the widget you created, e.g.
HTML:
<xf:if is="$xf.visitor.isMemberOf([5, 6, 7])">
    <xf:widget key="widget_key_for_your_widget" />
</xf:if>
 
I thought of that, the problem is although only the group defined sees the content everyone else sees the widget as an empty widget.

Or maybe I'm just doing it wrong.
 
It can work if I add it directly into a template of course instead of wrapping in an HTML widget and choosing a default display position
 
You'd need to click "Advanced mode" for the HTML widget. Sorry, forgot that bit. That should render it without a container and rely on the inner widget to do that (if visible).
 
Is it a plan for the future to set conditionals in widget settings? It's an important feature.

BTW.
Another nice to have widget position: everywhere in sidebar (y)
 
Eventually it is necessary to explain the forum rules clearer. No answer for a question means.....

1. No idea
2. I don't know
3. It isn't possible
4. It is possible but... (see 1.)
5. It's all the same to me
 
Back
Top Bottom