function theme_status_messages

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

6 theme calls to theme_status_messages()
ajax_prepare_response in drupal/core/includes/ajax.inc
Converts the return value of a page callback into an Ajax commands array.
file_ajax_upload in drupal/core/modules/file/file.module
Ajax callback: Processes file uploads and deletions.
hook_ajax_render_alter in drupal/core/modules/system/system.api.php
Alter the commands that are sent to the user through the Ajax framework.
template_preprocess_maintenance_page in drupal/core/includes/theme.inc
The variables array generated here is a mirror of template_preprocess_page(). This preprocessor will run its course when theme_maintenance_page() is invoked.
template_process_page in drupal/core/includes/theme.inc
Process variables for page.tpl.php

... See full list

File

drupal/core/includes/theme.inc, line 1600
The theme system, which controls the output of Drupal.

Code

function theme_status_messages($variables) {
  $display = $variables['display'];
  $output = '';
  $status_heading = array(
    'status' => t('Status message'),
    'error' => t('Error message'),
    'warning' => t('Warning message'),
  );
  foreach (drupal_get_messages($display) 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 .= $messages[0];
    }
    $output .= "</div>\n";
  }
  return $output;
}