XF 2.0 Turn .json link into widget

Cupara

Well-known member
I have a .json file used for my discord, I want to turn it into a widget, is that even possible? If so, can I get an explanation please as I have yet to figure it out.
 
You could either write your own widget class that extends \XF\Widget\AbstractWidget and add a widget definition for it in the ACP (you can tie these to add-ons if relevant to your use case), or use the PHP callback widget. With the latter, you give it a static method that takes the widget class as an argument:

PHP:
public static function renderWidget(\XF\Widget\AbstractWidget $widget)
{
    ...
}

Either way you'd probably fetch the JSON using the HTTP service and pass the relevant bits to a template for rendering.
 
Top Bottom