See also: Writing Registry Plugins
Some additional conventions are required when writing a Dashboard Widget Plugin.
- The name of the Plugin must match the format
FooWidget
. - The Plugin must implement a
CoFooWidget
model and a corresponding Controller.- The Model
CoFooWidget
should extendCoDashboardWidgetBackend
, which provides some behind the scenes common functionality. - The Controller should to extend
SDWController
("Standard Dashboard Widget" Controller), which provides some common functionality. The controller should use$this->calculateParentPermissions($roles);
to calculate permissions fordisplay()
, in accordance with the current user and the Dashboard's visibility. - When a new Dashboard Widget is instantiated, a skeletal row in the corresponding
co_foo_widgets
table will be created. There is noadd
operation or view required. The skeletal row will point to the parent Dashboard Widget Model. - When a Dashboard Widget Backend is edited, the entry point to the Dashboard Widget Plugin will be
foo_widget/foo_widgets/edit/#
. This will be called immediately after the Widget is first instantiated.
- The Model
- Note
CoDashboardWidget
has ahasOne
(ie: 1 to 1) relationship withFooWidget
. - The table
cm_foo_widgets
should include a foreign key tocm_dashboard_widgets:id
.- Other tables used by the plugin should reference
cm_foo_widgets:id
.
- Other tables used by the plugin should reference
- The Plugin must implement
CoFooWidgetsController::display($id)
, and a corresponding viewCoFooWidgets/display.ctp
. These will generate the widget's content when the dashboard is rendered.