diff --git a/message/classes/output/preferences/notification_list.php b/message/classes/output/preferences/notification_list.php index d112b4a66f0..5da29476625 100644 --- a/message/classes/output/preferences/notification_list.php +++ b/message/classes/output/preferences/notification_list.php @@ -167,8 +167,11 @@ class notification_list implements templatable, renderable { // // We only want the first component to render with the help icon. if (!empty($context['components'])) { - $context['components'][0]['onlinehelphtml'] = $output->help_icon('loggedin', 'message'); - $context['components'][0]['offlinehelphtml'] = $output->help_icon('loggedoff', 'message'); + $withnotifications = array_search(true, array_column($context['components'], 'hasnotifications'), true); + if ($withnotifications !== false) { + $context['components'][$withnotifications]['onlinehelphtml'] = $output->help_icon('loggedin', 'message'); + $context['components'][$withnotifications]['offlinehelphtml'] = $output->help_icon('loggedoff', 'message'); + } } return $context; diff --git a/message/classes/output/preferences/notification_list_component.php b/message/classes/output/preferences/notification_list_component.php index 8a77d9436cf..0be8973d4d7 100644 --- a/message/classes/output/preferences/notification_list_component.php +++ b/message/classes/output/preferences/notification_list_component.php @@ -160,6 +160,8 @@ class notification_list_component implements templatable, renderable { $context['notifications'][] = $notificationcontext; } + $context['hasnotifications'] = (count($context['notifications']) > 0); + return $context; } } diff --git a/message/templates/notification_preferences.mustache b/message/templates/notification_preferences.mustache index 9bc7cdd715e..f0536e61c2f 100644 --- a/message/templates/notification_preferences.mustache +++ b/message/templates/notification_preferences.mustache @@ -43,6 +43,7 @@ "offlinehelphtml": "
help button HTML
" } ], + "hasnotifications": 1, "notifications": [ { "displayname": "Notices about minor problems", diff --git a/message/templates/notification_preferences_component.mustache b/message/templates/notification_preferences_component.mustache index 0700fba8858..54fdfa9f5a0 100644 --- a/message/templates/notification_preferences_component.mustache +++ b/message/templates/notification_preferences_component.mustache @@ -28,6 +28,7 @@ Context variables required for this template: * displayname The component display name * processors The list of processors for this component + * hasnotifications Whether any notifications exist * notifications The list of notifications Example context (json): @@ -39,6 +40,7 @@ "offlinehelphtml": "help button HTML
" } ], + "hasnotifications": 1, "notifications": [ { "displayname": "Notices about minor problems", @@ -67,25 +69,27 @@ ] } }} -