Not a bug Add a widget key syntax in a template

Nicolas FR

Well-known member
Hi, I hope I could be clear, not being very familiar with (simple...) addon development yet.

I'm trying to display a widget in a template using an option field.
My option id is wbn_widgetKey1 and in a template modification I put this: {$xf.options.wbn_widgetKey1}.

the field to be filled is configured as follows:
  • Edit format : Text box
  • Format parameters : left empty
  • Data type : string
If I populate the field with <xf:widget key="forum_overview_members_online" /> this widget is not displayed as a awidget but as a simple text...

Capture web_2-12-2022_22334_localhost.jpeg

What is the solution to this problem? I tried a lot of combinations (a bit haphazardly) but my skills are already at their limit here...
Thanks for your help.
 

Nicolas FR

Well-known member
if I look at the source code of the page I see it displayed like this : &lt;xf:widget key=&quot;forum_overview_members_online&quot; /&gt;
 

Jeremy P

XenForo developer
Staff member
Template syntax is compiled into PHP and as such this won't really work the way you anticipate. You may wish to use an option with a set of values instead and then use a template modification to switch the widget key based on that value.
 
Top