New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Widgets API for plugins #7861
Comments
I started working on new WIdget API see new Widget base class https://github.com/piwik/piwik/compare/7861#diff-2627bb10f1c9060b562ef684be844e8dR1 and an example widget https://github.com/piwik/piwik/compare/7861#diff-328e5dc766c1f330bc3efc090ee7d32fR21 Fow now it is straight forward and very similar to the There are currently some "problems":
If any ideas or more feedback @mattab @diosmosis @mnapoli please comment. As more problems come up I will comment as well. Maybe something like this: class GetVisitorProfilePopup extends \Piwik\Plugin\Widget
{
public static function configure(WidgetConfig $config)
{
$config->setCategory('Live!');
$config->setName('Live_VisitorProfile');
$config->setOrder(25);
$config->disable();
}
public function render()
{
}
public static function configureWidgetsList(WidgetsList $widgetsList)
{
// only needed in rare cases when removing a widget or so
}
} WidgetConfig can be also used in a $config = new WidgetConfig();
$config->setCategory('Live!');
$config->setName(Piwik::translate('UserCountryMap_RealTimeMap'));
$config->setModule('UserCountryMap');
$config->setAction('realtimeMap');
$config->setOrder(5);
WidgetsList::getInstance()->addWidget($config);
// instead of
WidgetsList::add('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap', array(), $order = 5); And it will be probably used in reports to create a widget from a report eg protected function init()
{
parent::init();
$this->order = 2;
$this->createWidget()
->setName('Live_VisitorLog')
->setOrder(10)
->setParameters(array('small' => 1));
} |
fixed via #8442 |
While working on #7822 I noticed that it makes sense to change the Widgets API.
This is how we currently define a Widget: http://developer.piwik.org/guides/widgets
It was one of the first APIs that we revised and it works fine and is easy to use. Though it makes sense to refactor it with some features in mind etc. (#7822, #7131, #4734).
The API itself will look similar to a Report I reckon.
Widgets
Widgets\GetDonateForm.php
TODO:
Widgets::configureWidgetsList()
, shall we call this in each Widget itself?The text was updated successfully, but these errors were encountered: