diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 0edb028..575b05c 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1673,6 +1673,23 @@ function theme_status_messages($variables) { } /** + * Preprocess variables for theme_status_messages(). + * + * @param array $variables + * An associative array containing: + * - display: (optional) Set to 'status' or 'error' to display only messages + * of that type. + */ +function template_preprocess_status_messages(&$variables) { + $variables['messages_display'] = drupal_get_messages($variables['display']); + $variables['status_headings'] = array( + 'status' => t('Status message'), + 'error' => t('Error message'), + 'warning' => t('Warning message'), + ); +} + +/** * Returns HTML for a link. * * All Drupal code that outputs a link should call the l() function. That diff --git a/core/modules/system/templates/status-messages.html.twig b/core/modules/system/templates/status-messages.html.twig new file mode 100644 index 0000000..31d0517 --- /dev/null +++ b/core/modules/system/templates/status-messages.html.twig @@ -0,0 +1,34 @@ +{# +/** + * @file + * 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. + * + * Available variables: + * - messages_display: List of messages of all statuses which attempts to be + * displayed. + * - status_heading: List of all status types. + * + * @see template_preprocess_status_messages() + */ +#} + +{% for type, messages in messages_display %} +
+ {% if type in status_heading %} +

{{ status_heading[type] }}

+ {% endif %} + {% if messages|length > 1 %} + + {% else %} + {{ messages[0] }} + {% endif %} +
+{% endfor %}