Widgets

Dashboard widgets are Stream entries that are associated with an extension. The extensions along with configuration using the Configuration module.

Widget Fields

Below is a list of fields in the widgets stream. Fields are accessed as attributes:

$widget->title;

Same goes for decorated instances in Twig:

{{ widget.title }}
Fields
Key Type Description

title

text

The title.

description

textarea

The description.

extension

addon

The widget extension.

column

integer

The column placement.

pinned

boolean

The pinned state.

dashboard

relationship

The related dashboard.

allowed_roles

multiple

The roles allowed to view the widget.

Widget Interface

This section will go over the \Anomaly\DashboardModule\Widget\Contract\WidgetInterface class.

WidgetInterface::output()

The output method returns the complete widget output.

Returns: string
Example
$widget->output();
Twig
{{ widget.output()|raw }}
WidgetInterface::addData()

The addData method adds data to the widget's data for access later in processing and output.

Returns: \Anomaly\Streams\Platform\Entry\Contract\EntryInterface
Arguments
Key Required Type Default Description

$key

true

string

none

The data key.

$data

true

mixed

none

The data.

Example
$widget->addData('example', 'http://pyrocms.com');
WidgetInterface::getData()

The getData method returns the widget's data collection.

Returns: \Anomaly\DashboardModule\Widget\WidgetData
Example
$widget->getData()->get('example');
Twig
{{ widget.getData().get('example') }}
WidgetInterface::setContent()

The setContent method sets the interior content for the widget wrapper view.

Returns: \Anomaly\DashboardModule\Widget\Contract\WidgetInterface
Arguments
Key Required Type Default Description

$content

true

string

none

The rendered content.

Example
$widget->setContent($html);
WidgetInterface::getContent()

The getContent method gets the interior content for the widget wrapper view.

Returns: string
Example
$widget->getContent();
Twig
{{ widget.getContent()|raw }}