1 theme.inc theme_status_messages($variables)

Returns HTML for status and/or error messages, grouped by type.

An invisible heading identifies the messages for assistive technology. Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html for info.

Parameters

$variables: An associative array containing:

  • display: (optional) Set to 'status' or 'error' to display only messages of that type.

Related topics

File

core/includes/theme.inc, line 1726
The theme system, which controls the output of Backdrop.

Code

function theme_status_messages($variables) {
  $display = $variables['display'];
  $message_types = (empty($variables['messages'])) ? backdrop_get_messages($display) : $variables['messages'];
  $output = '';

  $status_heading = array(
    'status' => t('Status message'),
    'error' => t('Error message'),
    'warning' => t('Warning message'),
    'info' => t('Info message'),
  );

  foreach ($message_types as $type => $messages) {
    $output .= "<div class=\"messages $type\">\n";
    if (!empty($status_heading[$type])) {
      $output .= '  <h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
    }
    if (count($messages) > 1) {
      $output .= "  <ul>\n";
      foreach ($messages as $message) {
        $output .= '    <li>' . $message . "</li>\n";
      }
      $output .= "  </ul>\n";
    }
    else {
      $output .= reset($messages) . "\n";
    }
    $output .= "</div>\n";
  }

  return $output;
}