Creating Dashboard Widgets¶
Creating widgets is simple. First, create the html code for the widget, save it
to a file named
widget_name.widget.php, and put it into the
/usr/local/www/widgets/widgets directory on the firewall.
Do not include any
$pgtitle definitions, etc.
Only include basic HTML code for what needs to be displayed. Examine the current
widget source code for examples.
The file must be named in the
my_name.widget.php format. No spaces are
allowed in the filename. The name the GUI displays is the name of the file. For
example the Traffic Graphs widget file is named
And that’s it! The dashboard handles the rest of the widget behavior (e.g. buttons, border, dragging, sequence, etc.) automatically.
To include custom code into the widget upon rendering:
Create a file named
widget_name.incand place the
.incfile in the
Create a file named
widget_name.jsand place the
.jsfile in the
Saving configuration data for a widget requires more work and is beyond the scope of this document. Look at the source code for existing widgets which have settings and follow their example, including:
The form for the settings and all related fields, save button, etc.
Storing settings by writing the configuration
Redirect the user back to the dashboard
Customizing the Title and Linking to page¶
By default the name of the widget file is what is shown on the Widget in the dashboard. This title can be changed and also have a link to another page inserted.
To configure the widget to use a certain name other than the name of the file,
.inc file with the same base name as the widget and place that
file into the
For example if a widget is named
abc.widget.php, the include file must be
.inc file use the following code:
<?php //set variable for custom title $abc_title = "A B C custom"; $abc_title_link = "abc.php"; ?>
Use the widget name in the variable names as shown in the example.
An example of these values can be taken from the
interfaces.inc file for the
<?php [...] $interfaces_title = gettext("Interfaces"); $interfaces_title_link = "status_interfaces.php"; ?>