See also: Writing Registry Plugins

Some additional conventions are required when writing a Dashboard Widget Plugin.

  1. The name of the Plugin must match the format FooWidget.
  2. The Plugin must implement a CoFooWidget model and a corresponding Controller.
    1. The Model CoFooWidget should extend CoDashboardWidgetBackend, which provides some behind the scenes common functionality.
    2. 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 for display(), in accordance with the current user and the Dashboard's visibility.
    3. When a new Dashboard Widget is instantiated, a skeletal row in the corresponding co_foo_widgets table will be created. There is no add operation or view required. The skeletal row will point to the parent Dashboard Widget Model.
    4. 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.
  3. Note CoDashboardWidget has a hasOne (ie: 1 to 1) relationship with FooWidget.
  4. The table cm_foo_widgets should include a foreign key to cm_dashboard_widgets:id.
    1. Other tables used by the plugin should reference cm_foo_widgets:id.
  5. The Plugin must implement CoFooWidgetsController::display($id), and a corresponding view CoFooWidgets/display.ctp. These will generate the widget's content when the dashboard is rendered.

    The widget should always render content, even if there is no "relevant" content to render. In such cases, render a message like "No Foos found."


  6. The Plugin's instantiated configuration is available in $this->CoFooWidget->getConfig().
  7. If the Plugin is rendering CO Person-specific content, the CO Person ID for which the widget should render content is available in $this->reqCoPersonId. Use this rather than reading session information to allow support for administrators viewing Dashboards as other users.