From 0ee8369af5d00202435abebc75dc16699f31f40f Mon Sep 17 00:00:00 2001 From: Andy Broomfield Date: Mon, 31 Jul 2023 19:32:13 +0100 Subject: [PATCH] Hide moderation controls when present on confirmation form page Fix #236 Adds a preprocess implementation to the alert banner to hide the moderation controls if they have been displayed when on the confirmation page (status form). Note: This only hides on the confirmation form page eg. /admin/content/alert-banner/18/status If the form is included in another way it will still be present. This way, moderation controls can be placed on an alert banner manage display if a site builder considers that desirable, without interfering with the confirmation form to put an alert banner live. --- localgov_alert_banner.module | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/localgov_alert_banner.module b/localgov_alert_banner.module index 93b073d..a1691bd 100644 --- a/localgov_alert_banner.module +++ b/localgov_alert_banner.module @@ -40,6 +40,13 @@ function localgov_alert_banner_preprocess(&$variables) { // Token as attribute. $variables['attributes']['data-dismiss-alert-token'] = $token; + // Remove the content moderation form if it is present. + // Do this only on the confirmation form page. + $route_match = \Drupal::routeMatch(); + $route_name = $route_match->getRouteName(); + if ($route_name == 'entity.localgov_alert_banner.status_form') { + unset($variables['content']['content_moderation_control']); + } } }