Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

opReports versions 3.0.8 and newer provide various mechanisms that let you adjust the styling of HTML reports. These mechanisms are primarily aimed at a report's "standalone" display, i.e. when the report is saved as ZIP file or emailed to somebody, and do not apply when the report is viewed in "embedded mode" , within the application.

Custom Banner

...

opReports automatically includes or attaches a CSS style sheed and a Javascript file with any HTML report.

The following configuration options define which files get attached:

Code Block
'opreports_default_css' => '<omk_public>/omk/css/opReports_report.css',
'opreports_default_js' => '<omk_public>/omk/js/opReports_report.js',

If you want to make changes it's recommended that you copy these files,  edit the copies and update the configuration; the installer will overwrite the default files on upgrade, and any changes to those files would therefore be lost.

Custom Templates

Since version 3.0.8 opReports' HTML reports are templated which simplifies customisation by end-users.

Each opReports HTML report involves two templates:

Limitations and Caveats

  • This functionality is meant for advanced users!
    You need to learn a little bit about Mojo Templates and you'll likely have to experiment a little before success.
  • Template modifications do cause installer warnings on upgrades, and by default the installer will overwrite all templates!
    It is vital that you keep backups of your custom templates and manually merge or restore your desired customisations after an opReport upgrade.

Custom Logos

In opReports 3.0.10 we've added the ability to attach and associate arbitrary files with a report instance.

Table of Contents

Overview

opReports versions 3.0.8 and newer provide various mechanisms that let you adjust the styling of HTML reports. These mechanisms are primarily aimed at a report's "standalone" display, i.e. when the report is saved as ZIP file or emailed to somebody, and do not apply when the report is viewed in "embedded mode", within the application.

Custom Banner

To add a custom banner before the report content, you can use the report option homelink: if set to a string of HTML that  html will be inserted before the report.

Please note that this option is available only for scheduled reports, and affects the report only if viewed in standalone fashion.

Custom CSS and JavaScript

opReports automatically includes or attaches a CSS style sheed and a sheet and a Javascript file with any HTML report.

...

If you want to make changes it's recommended that you copy these files,  edit the copies and update the configuration; the installer will overwrite the default files on upgrade, and any changes to those files would therefore be lost.

Custom Templates

Since version 3.0.8 opReports' HTML reports are templated which simplifies customisation by end-users.

...

Please refer to the provided standard report templates for details regarding the data interface.

Limitations and Caveats

  • This functionality is meant for advanced users only!
    You need to learn a little bit about Mojo Templates and you'll likely have to experiment a little before achieving full success.
  • The data interface between opReports and the templates will likely is subject to change slighlty between versions.
  • Template modifications do cause installer warnings on upgrades, and by default the installer will overwrite all templates!
    It is vital that you keep backups of your custom templates and manually merge or restore your desired customisations after an opReport upgrade.
  • The report_wrapper template contains two crucial markers that control its dual functionality:
    Everything before  '<!-- report body start 7fd66b21f83244e6ca07cf27dbac3b0c -->'  and the corresponding 'body end' marker is omitted when the report is shown in embedded mode.
    It is therefore crucial that you put your changes in the appropriate place, i.e. custom headings or logos should go on the inside of this marker set.

Custom Logos, other Custom Attachments

...

When opReports creates a report in HTML format, all custom files defined at the time of report creation are copied and attached to the report. Every HTML report will have copies of all defined custom files attached, and it's inadvisable to use very large files in this situation.

All custom files are copied and saved separately with every report instance, and the per-report copies are saved with a dynamically generated globally unique file name.

Access to Custom Files for Visualisation

Custom files cannot be referenced by their original file names, as only the per-report copy is included with the report, and that has a dynamically generated file name. This means that referencing such files from a CSS stylesheet is likely not possible. However, from a report template this information is easy to access, and may very well be saved in the HTML as a Javascript map object or HTML attribute.

The report's two templates can refer to the report's copies of the any custom files by accessing the data interface variable $report->{meta}->{moduleurls},which is a hash datastructure (key: the full "original" path given in opreports_custom_files, value: a suitable safe relative URL the unique file name for that file and this report, which works fine as a safe relative url for it).

The standard wrapper template contains this usage example, which produces an HTML comment for every custom file involved:

...