Outputting different class other than default for status messages I'm trying to theme status messages, I want to change the HTML of the message.

Drupal default is 

 &lt;div class="message status"&gt;message!&lt;/div&gt;


What I want to achieve is

 &lt;div class="alert alert-success"&gt;message!&lt;/div&gt;


I have used theme_status_messages to modify 'messages' but how can I modify the type (e.g. 'status'/'warning', etc)?

This is current code

function theme_status_messages($variables) {
  $display = $variables['display'];
  $output = '';

  $status_heading = array(
    'status' =&gt; t('Status message'),
    'error' =&gt; t('Error message'),
    'warning' =&gt; t('Warning message'),
  );
  foreach (drupal_get_messages($display) as $type =&gt; $messages) {
    $output .= "&lt;div class=\"alert $type\"&gt;\n";
    if (!empty($status_heading[$type])) {
      $output .= '&lt;h2 class="element-invisible"&gt;' . $status_heading[$type] . "&lt;/h2&gt;\n";
    }
    if (count($messages) &gt; 1) {
      $output .= " &lt;ul&gt;\n";
      foreach ($messages as $message) {
        $output .= '  &lt;li&gt;' . $message . "&lt;/li&gt;\n";
      }
      $output .= " &lt;/ul&gt;\n";
    }
    else {
      $output .= $messages[0];
    }
    $output .= "&lt;/div&gt;\n";
  }
  return $output;
}


I've changed this line

$output .= "&lt;div class=\"messages $type\"&gt;\n";


to

$output .= "&lt;div class=\"alert $type\"&gt;\n";


as you can see in my code above, but how can I change the options for $type?? I want my types to be alert-success, alert-error, alert-warning, rather than status, error, warning.

Anyone got an idea?

thanks!
This is just some good old PHP logic, is this what you're after?

function theme_status_messages($variables) {
  $display = $variables['display'];
  $output = '';

  $status_heading = array(
    'status' =&gt; t('Status message'),
    'error' =&gt; t('Error message'),
    'warning' =&gt; t('Warning message'),
  );

  // Map our drupal statuses to bootstrap classes
  $bootstrap_statuses = array(
    'status' =&gt; 'alert-success',
    'error' =&gt; 'alert-error',
    'warning' =&gt; 'alert-warning',
  );

  foreach (drupal_get_messages($display) as $type =&gt; $messages) {
    // Grab the bootstrap class that corresponds to $type
    $bootstrap_class = $bootstrap_statuses[$type];
    $output .= "&lt;div class=\"alert $bootstrap_class\"&gt;\n";
    if (!empty($status_heading[$type])) {
      $output .= '&lt;h2 class="element-invisible"&gt;' . $status_heading[$type] . "&lt;/h2&gt;\n";
    }
    if (count($messages) &gt; 1) {
      $output .= " &lt;ul&gt;\n";
      foreach ($messages as $message) {
        $output .= '  &lt;li&gt;' . $message . "&lt;/li&gt;\n";
      }
      $output .= " &lt;/ul&gt;\n";
    }
    else {
      $output .= $messages[0];
    }
    $output .= "&lt;/div&gt;\n";
  }
  return $output;
}


You could even put the $bootstrap_classes and $status_heading arrays together. But I separated them for simplicity