« Back to Product

Documentation

IPS_GetVisualizationTile

 string IPS_GetVisualizationTile (int $InstanceID) 

Parameters

InstanceID

ID of the instance

Returns

If the function is executed successfully, it returns the HTML content of the custom presentation of the instance. If the instance has no custom presentation, the string can be empty.

Description

Returns the HTML content of the custom presentation of the instance with the ID InstanceID, as displayed by the tile visualization for the tile of the instance.

Modules provide this content via the HTML-SDK by overriding the module function GetVisualizationTile. IPS_GetVisualizationTile calls this function for the given instance. For PHP modules, a <script> block is prepended to the return value that contains the JavaScript functions of the HTML-SDK as well as the translations from the locale.json of the module. This block is also present if the module does not override GetVisualizationTile. For the modules built into IP-Symcon the function returns an empty string.

The following errors are possible:

  • If the instance does not exist, the function fails with "Instance #... does not exist".
  • If InstanceID is outside of the valid range, it fails with "Parameter for InstanceID is not inside of the specified bounds (0..…)".
  • If the instance could not be loaded, e.g. because the associated module is not available, it fails with "InstanceInterface is not available".

Example

// Read the custom presentation of instance 12345 and save it as an HTML file
$html = IPS_GetVisualizationTile(12345);
if ($html === '') {
    echo "The instance has no custom presentation";
} else {
    file_put_contents(IPS_GetKernelDir() . 'tile.html', $html);
    echo strlen($html) . " bytes saved";
}
Any questions?