Piwik\Widget\
Defines a new widget container.
To define a widget container just place a subclass within the Widgets folder of your plugin.
The class defines the following methods:
setCategoryId() ash; Set the id of the category the widget belongs to. Inherited from WidgetConfiggetCategoryId() ash; Get the id of the category the widget belongs to. Inherited from WidgetConfigsetSubcategoryId() ash; Set the id of the subcategory the widget belongs to. Inherited from WidgetConfiggetSubcategoryId() ash; Get the currently set category ID. Inherited from WidgetConfigsetModule() ash; Set the module (aka plugin name) of the widget. Inherited from WidgetConfiggetModule() Inherited from WidgetConfigsetAction() ash; Set the action of the widget that shall be used in the URL to render the widget. Inherited from WidgetConfiggetAction() ash; Get the currently set action. Inherited from WidgetConfigsetParameters() ash; Sets (overwrites) the parameters of the widget. Inherited from WidgetConfigaddParameters() ash; Add new parameters and only overwrite parameters that have the same name. Inherited from WidgetConfiggetParameters()setName() ash; Set the name of the widget. Inherited from WidgetConfiggetName() ash; Get the name of the widget. Inherited from WidgetConfigsetOrder() ash; Set the order of the widget. Inherited from WidgetConfiggetOrder() ash; Returns the order of the widget. Inherited from WidgetConfigisEnabled() ash; Defines whether a widget is enabled or not. Inherited from WidgetConfigsetIsEnabled() ash; Enable / disable the widget. Inherited from WidgetConfigenable() ash; Enables the widget. Inherited from WidgetConfigdisable() ash; Disables the widget. Inherited from WidgetConfigcheckIsEnabled() ash; This method checks whether the widget is available, see isEnabled(). Inherited from WidgetConfiggetUniqueId()setIsNotWidgetizable() ash; Sets the widget as not widgetizable isWidgetizeable(). Inherited from WidgetConfigsetIsWidgetizable() ash; Sets the widget as widgetizable isWidgetizeable(). Inherited from WidgetConfigisWidgetizeable() ash; Detect whether the widget is widgetizable meaning it won't be able to add it to the dashboard and it won't be possible to export the widget via an iframe if it is not widgetizable. Inherited from WidgetConfigsetMiddlewareParameters() ash; If middleware parameters are specified, the corresponding action will be executed before showing the actual widget in the UI. Inherited from WidgetConfiggetMiddlewareParameters() ash; Get defined middleware parameters (if any). Inherited from WidgetConfigsetIsWide() ash; Marks this widget as a "wide" widget that requires the full width. Inherited from WidgetConfigisWide() ash; Detect whether the widget should be shown wide or not. Inherited from WidgetConfigsetId() — Sets (overwrites) the id of the widget container.getId() — Get the id of the widget.setLayout() — Sets the layout of the container widget.getLayout() — Gets the currently set layout.addWidgetConfig() — Adds a new widget to the container widget.setWidgetConfigs() — Set (overwrite) widget configs.getWidgetConfigs() — Get all added widget configs.setCategoryId()Set the id of the category the widget belongs to.
$categoryId (string) —
Usually a translation key, eg 'General_Visits', 'Goals_Goals', ...WidgetConfig value.getCategoryId()Get the id of the category the widget belongs to.
string value.setSubcategoryId()Set the id of the subcategory the widget belongs to. If a subcategory is specified, the widget will be shown in the Matomo (formerly Piwik) reporting UI. The subcategoryId will be used as a translation key for the submenu item.
$subcategoryId (string) —
Usually a translation key, eg 'General_Overview', 'Actions_Pages', ...WidgetConfig value.getSubcategoryId()Get the currently set category ID.
string value.setModule()Set the module (aka plugin name) of the widget. The correct module is usually detected automatically and not needed to be configured manually.
$module (string) —
eg 'CoreHome'WidgetConfig value.getModule()setAction()Set the action of the widget that shall be used in the URL to render the widget.
The correct action is usually detected automatically and not needed to be configured manually.
$action (string) —
eg 'renderMyWidget'WidgetConfig value.getAction()Get the currently set action.
string value.setParameters()Sets (overwrites) the parameters of the widget. These parameters will be added to the URL when rendering the widget. You can access these parameters via `Piwik\Common::getRequestVar(.
..)`.
$parameters (array) —
eg. ('urlparam' => 'urlvalue')WidgetConfig value.addParameters()Add new parameters and only overwrite parameters that have the same name. See setParameters()
$parameters (array) —
eg. ('urlparam' => 'urlvalue')WidgetConfig value.getParameters()array —
Eg ('urlparam' => 'urlvalue').setName()Set the name of the widget.
$name (string) —
Usually a translation key, eg 'VisitTime_ByServerTimeWidgetName'WidgetConfig value.getName()Get the name of the widget.
string value.setOrder()Set the order of the widget.
$order (int) —
eg. 5WidgetConfig value.getOrder()Returns the order of the widget.
int value.isEnabled()Defines whether a widget is enabled or not. For instance some widgets might not be available to every user or
might depend on a setting (such as Ecommerce) of a site. In such a case you can perform any checks and then
return true or false. If your report is only available to users having super user access you can do the
following: return Piwik::hasUserSuperUserAccess();
bool value.setIsEnabled()Enable / disable the widget. See isEnabled()
It accepts the following parameter(s):
$isEnabled (bool) —It returns a WidgetConfig value.
enable()Enables the widget. See isEnabled()
disable()Disables the widget. See isEnabled()
checkIsEnabled()This method checks whether the widget is available, see isEnabled(). If not, it triggers an exception containing a message that will be displayed to the user. You can overwrite this message in case you want to customize the error message. Eg.
if (!$this->isEnabled()) {
throw new Exception('Setting XYZ is not enabled or the user has not enough permission');
}
getUniqueId()string value.setIsNotWidgetizable()Sets the widget as not widgetizable isWidgetizeable().
WidgetConfig value.setIsWidgetizable()Sets the widget as widgetizable isWidgetizeable().
WidgetConfig value.isWidgetizeable()Detect whether the widget is widgetizable meaning it won't be able to add it to the dashboard and it won't be possible to export the widget via an iframe if it is not widgetizable. This is usually not needed but useful when you eg want to display a widget within the Matomo UI but not want to have it widgetizable.
bool value.setMiddlewareParameters()If middleware parameters are specified, the corresponding action will be executed before showing the
actual widget in the UI. Only if this action (can be a controller method or API method) returns JSON true
the widget will be actually shown. It is similar to isEnabled() but the specified action is performed each
time the widget is requested in the UI whereas isEnabled is only checked once on the initial page load when
we load the initial list of widgets. So if your widget's visibility depends on archived data
(aka idSite/period/date) you should specify middle parameters. This has mainly two reasons:
isEnabled is only
checked once on the initial Matomo page load.$parameters (array) —
URL parameters eg array('module' => 'Goals', 'action' => 'Conversions')WidgetConfig value.getMiddlewareParameters()Get defined middleware parameters (if any).
array value.setIsWide()Marks this widget as a "wide" widget that requires the full width.
$this value.isWide()Detect whether the widget should be shown wide or not.
bool value.setId()Sets (overwrites) the id of the widget container.
The id can be used by any plugins to add more widgets to this container and it will be also used for the unique widget id and in the URL to render this widget.
$id (string) —
eg 'Products' or 'Contents'WidgetContainerConfig value.getId()Get the id of the widget.
string value.setLayout()Sets the layout of the container widget.
By default widgets within a container are displayed one after another. In case you want to change this behaviour you can specify a layout that will be recognized by the UI. It is not yet possible to define custom layouts.
$layout (string) —
eg 'ByDimension' see Piwik\Plugins\CoreHome\CoreHome::WIDGET_CONTAINER_LAYOUT_BY_DIMENSIONWidgetContainerConfig value.getLayout()Gets the currently set layout.
string value.addWidgetConfig()Adds a new widget to the container widget.
It accepts the following parameter(s):
$widget (WidgetConfig) —It returns a WidgetContainerConfig value.
setWidgetConfigs()Set (overwrite) widget configs.
It accepts the following parameter(s):
$configs (WidgetConfig[]) —It does not return anything or a mixed result.
getWidgetConfigs()Get all added widget configs.
WidgetConfig[] value.