diff --git a/CHANGELOG.md b/CHANGELOG.md index 9973af9365fec4708ceb7e994ff9321777fedf20..c11a4e1334fd9b2183432f9de0c1baab3a4609d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The Product Changelog at **[piwik.org/changelog](https://piwik.org/changelog)** ### New APIs * Reports and visualizations can now hide the export icons with a new property `$view->config->show_export`. +* Reports and visualizations can now show a message above the report with a new property `$view->config->show_header_message`. * The following events have been added: * `Metric.addMetrics` Triggered to add new metrics that cannot be picked up automatically by the platform. * `Metric.addComputedMetrics` Triggered to add computed metrics that are not generated automatically diff --git a/core/Plugin/Visualization.php b/core/Plugin/Visualization.php index 6bb2c3a4f8041dcd501e7f4f9a9c417adb55edda..bd46547e6486ad5dfcee36ea20072d633054cf41 100644 --- a/core/Plugin/Visualization.php +++ b/core/Plugin/Visualization.php @@ -38,6 +38,7 @@ use Piwik\API\Request as ApiRequest; * itself: * * - report documentation, + * - a header message (if {@link Piwik\ViewDataTable\Config::$show_header_message} is set), * - a footer message (if {@link Piwik\ViewDataTable\Config::$show_footer_message} is set), * - a list of links to related reports (if {@link Piwik\ViewDataTable\Config::$related_reports} is set), * - a button that allows users to switch visualizations, diff --git a/core/ViewDataTable/Config.php b/core/ViewDataTable/Config.php index 2c7a59beffc0dda53d680c5e68f318110e8ea15b..2a2a927da4c1d6ff9b9a1aaceaba026eea2cbc25 100644 --- a/core/ViewDataTable/Config.php +++ b/core/ViewDataTable/Config.php @@ -371,8 +371,17 @@ class Config */ public $show_ecommerce = false; + /** + * Stores an HTML message (if any) to display above the datatable view. + * + * Attention: Message will be printed raw. Don't forget to escape where needed! + */ + public $show_header_message = false; + /** * Stores an HTML message (if any) to display under the datatable view. + * + * Attention: Message will be printed raw. Don't forget to escape where needed! */ public $show_footer_message = false; diff --git a/plugins/CoreHome/stylesheets/dataTable/_dataTable.less b/plugins/CoreHome/stylesheets/dataTable/_dataTable.less index 2015f6ea2eb2a46e955ea7b3e3720d0d8e28dd3e..fe11180aa86f2112cc62e94275fd88b117c73b20 100644 --- a/plugins/CoreHome/stylesheets/dataTable/_dataTable.less +++ b/plugins/CoreHome/stylesheets/dataTable/_dataTable.less @@ -183,7 +183,7 @@ table.dataTable img { position: absolute; } -.datatableFooterMessage { +.datatableHeaderMessage, .datatableFooterMessage { color: #888; text-align: left; margin: 10px; diff --git a/plugins/CoreHome/templates/_dataTable.twig b/plugins/CoreHome/templates/_dataTable.twig index b5635d99212a607099a1f8597c93d9572e296168..cdd5905933afc311e6eeb5e4af32ae35db720cdb 100644 --- a/plugins/CoreHome/templates/_dataTable.twig +++ b/plugins/CoreHome/templates/_dataTable.twig @@ -49,6 +49,10 @@ {% if error is defined %} {{ error.message }} {% else %} + {% if properties.show_header_message is defined and properties.show_header_message is not empty %} + <div class='datatableHeaderMessage'>{{ properties.show_header_message | raw }}</div> + {% endif %} + {% if isDataTableEmpty %} <div class="pk-emptyDataTable"> {% if showReportDataWasPurgedMessage is defined and showReportDataWasPurgedMessage %} diff --git a/plugins/Dashboard/stylesheets/widget.less b/plugins/Dashboard/stylesheets/widget.less index 8127de0547bf3c1b3fc71fcb631bea1249d6482a..c441b9c663a4ea1bffc43479561b7a3909c8e0c1 100644 --- a/plugins/Dashboard/stylesheets/widget.less +++ b/plugins/Dashboard/stylesheets/widget.less @@ -140,8 +140,10 @@ background-color: @theme-color-widget-background; } -.widget .datatableFooterMessage { - padding-left: 12px; +.widget { + .datatableHeaderMessage, .datatableFooterMessage { + padding-left: 12px; + } } .bar-graph-colors[data-name=grid-background] { diff --git a/plugins/Morpheus/stylesheets/main.less b/plugins/Morpheus/stylesheets/main.less index cbf86d85cdc507db8280f8bfa678be9835041f59..c79bde51a8996c6608ba9bd29561f0105558772f 100644 --- a/plugins/Morpheus/stylesheets/main.less +++ b/plugins/Morpheus/stylesheets/main.less @@ -510,7 +510,7 @@ div.sparkline { color: @theme-color-text; } -.datatableFooterMessage { +.datatableHeaderMessage, .datatableFooterMessage { .font-default(13px, 18px); color: @color-silver; font-weight: normal;