Dashboard
Creating widgets#
In order to create your own widgets you need at least three files: one for the controller, two for the Views:
Controller#
In this case, the controller is a widget-plug-in under site/modules/core/Dynamic/Widget
.
The easiest way is to copy an existing widget and modify the values, for example the clock-widget:
package Dynamic::Widget::Clock;
use strict;
use base qw(Imperia::Dashboard::Widget);
use Imperia::Util::String::HTML qw(escape_js);
use Locale::TextDomain qw(imperia);
sub name {
return __ ('Clock')
}
sub description {
return __ ('Configurable clock for different time zones.')
}
sub icon {
return '/imperia/images/icons/white/png/20x18/time.png'
}
sub new {
my ($class, $args) = @_;
my $self = $class->SUPER::new($args,
{
templates => {
edit => 'controllers/widget/clock/edit.html',
widget_content => 'controllers/widget/clock/content.html',
},
head_icon => icon(),
default_parameters => {
title => name(),
disableReload => 'true',
clock_name_1 => '',
clock_offset_1 => 0,
clock_name_2 => '',
clock_offset_2 => 0,
clock_name_3 => '',
clock_offset_3 => 0,
}
}
);
return $self;
}
1;
Views#
-
For the configuration
/site/view/imperia/default/controllers/widget/XY/edit.html\
-
For the output of the content
/site/view/imperia/default/controllers/widget/XY/content.html\