Skip to content

Commit

Permalink
Add the is_front template flag using path.matcher service
Browse files Browse the repository at this point in the history
Fix #279

Same method as page manager.
This adds the is_front template flag to localgov alert banner for testing with twig.
Will restore the default homepage class in the default template.
  • Loading branch information
andybroomfield committed Aug 30, 2023
1 parent f0ef42d commit ae55b3a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions localgov_alert_banner.module
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ function localgov_alert_banner_preprocess(&$variables) {
if ($route_name == 'entity.localgov_alert_banner.status_form') {
unset($variables['content']['content_moderation_control']);
}

// Set is_front variable.
try {
$variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage();
}
catch (Exception $e) {
$variables['is_front'] = FALSE;
}
}
}

Expand Down

0 comments on commit ae55b3a

Please sign in to comment.