XF 2.2 How to pass data/values to <xf:widget>

jb-net

Active member
Hi,

I'm trying to add a search forum widget to my template by using the xf:widget syntax. My goal is to save the settings for the Widget in custom thread fields. But I think I need some help. Until now I tried:

Code:
<xf:widget class="XF\Widget\SearchForum" node_id="123" />
<xf:widget class="XF\Widget\SearchForum" params="{{ {'node_id': '123'} }}" />

The value 123 would be dynamic and would be replaced with a variable from custom thread fields. I can't us a manually created widget because I would need about 200 of different possible combinations.

I think in theory this should be possible:
  • You can also provide widget-specific options as attributes when the class attribute is used.

But I have problems getting it to work. Any suggestions?

Thanks!
 
Last edited:
There's an options param in the php code that holds json. Perhaps that could work instead of your params example above.

But, it appears the built in search forum picker only takes one widget. you may need to define a custom call back that handles a dynamic selection.
 
Back
Top Bottom