You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.

Presentation

Widget presentation is part of the widget module that receives the data according to the configuration and displays it on the dashboard in a container. Widget presentation container can be positioned and resized.

The widget view consists of two optional parts:

Widget actions

The majority of widget actions use and/or extend the default controller class CControllerDashboardWidgetView. This class contains methods for operations with widgets in the view mode.

The class source file must be located in the actions directory and must be specified as an action class in the manifest.json in the actions/widget.{id}.view/class section.

For example, this is how extending the default class is implemented in the Zabbix-native widget System information:

class WidgetView extends CControllerDashboardWidgetView {
       
           protected function doAction(): void {
               $this->setResponse(new CControllerResponseData([
                   'name' => $this->getInput('name', $this->widget->getDefaultName()),
                   'system_info' => CSystemInfoHelper::getData(),
                   'info_type' => $this->fields_values['info_type'],
                   'user_type' => CWebUser::getType(),
                   'user' => [
                       'debug_mode' => $this->getDebugMode()
                   ]
               ]));
           }
       }

Widget view

Widget presentation view is being built by class CWidgetView.

(new CWidgetView($data))
           ->addItem(
               new CTag('h1', true, $data['name'])
           )
           ->show();

The widget's view file should be located in the views directory. If the file has a default name widget.view.php, there is no need to register it in the manifest.json. If the file has a different name, specify it in the actions/widget.{id}.view/view section of manifest.json.