i wrote a plugin with an additional dashboard widget.
i have to refresh the widget data every hour with ajax. so i added a plugin controller in my plugin directory with the idea of re-rendering the widget template (called through ajax).
1) how can i (correctly) access the widget instance from the controller (or service)?
my try is $widget = craft()->dashboard->getWidgetType('name'). this gives me the correct instance. is this the right way?
2) no settings data from widget (needed in widget template)
in the widget template i need access to the widget settings (defined in the widget class with defineSettings()).
in the controller, i get the widget instance (as described in point 1) and do $widget->getBodyHtml(), but the settings attributes are empty. all other parts of the template are rendered correctly.
when the widget is rendered the first time (no ajax request), anything seems to be fine (settings loaded correctly).
can anyone explain my fault?
craft()->templates->render()
?craft()->templates->render()
option (return craft()->templates->render('showcase/_statsView', ['settings' => $this->getSettings()]);
. when i dump the$this->getSettings()
in the widget class (ongetBodyHtml
-method, the first time it renders the settings property is populated, but the second time (with an ajax-request), the property is empty.