XF 2.3 Passing widget vars through to templates?

eDaddi

Active member
Licensed customer
I have an HTML widget, it includes another vendor's add-on Widget, their widget calls it's own template for that part.

In my HTML widget, I set a few variables with <xf:set var= and was hoping it would pass through to the add-on's template but it no-werky.

Suggestions?
 
I know it's an old post, but I thought it'd be useful to have an answer for future searchers.
You can't use <xf:set> because the scope is limited to the widget being rendered. However say widget1 is the "parent" can calls widget2. In widget1 we have:
Code:
<xf:widget key="widget2"/>
If instead we use a form like this:
Code:
<xf:widget key="widget2" context-myvar="hello"/>
That is passed over to the rendering context and in widget2 we can read that variable thus:
Code:
{{ $context.myvar }}
You can pass multiple variables like this:
Code:
<xf:widget key="widget2" context-myvar="hello" context-myvar2="world"/>
I can't fully say if those variables are going to get passed down into the template of the custom widget OP asks about, but the above certainly works if you have say two HTML widgets.
 
Last edited:
Back
Top Bottom