Developer Documentation

When creating a theme, you might want to just hard-code the Alert Display Area block into your theme. You can use the following syntax to do this: 

<?php
    $alerts = BlockType::getByHandle('alert_display_area');
    $alerts->render('view');
?>
 
Or if you would like to display one of the custom templates: 
 
<?php
    $alerts = BlockType::getByHandle('alert_display_area');
    $alerts->render('templates/bootstrap');
?>
 
 
If you want even more control, you can use the AlertService class to manually pull the alerts and display them however you like. The common methods are the following: 
 
<?php
$alertService = Core::make('site_alerts/alert_service');
 
// All active alerts, excluding those that have been dismissed by the user
$alerts = $alertService->getAlertsForUserOnPage();
 
// All active alerts, including those that have been dismissed
$alerts = $alertService->getAlertsForPage();
 
// All alerts
$alerts = $alertService->getActiveAlerts();
?>