drupal_set_message

5 bootstrap.inc drupal_set_message($message = NULL, $type = 'status')
6 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
7 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
8 bootstrap.inc drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)

Set a message which reflects the status of the performed operation.

If the function is called with no arguments, this function returns all set messages without clearing them.

Parameters

$message: The message should begin with a capital letter and always ends with a period '.'.

$type: The type of the message. One of the following values are possible:

  • 'status'
  • 'error'

106 calls to drupal_set_message()

File

includes/bootstrap.inc, line 722
Functions that need to be loaded on every Drupal request.

Code

function drupal_set_message($message = NULL, $type = 'status') {
  if ($message) {
    if (!isset($_SESSION['messages'])) {
      $_SESSION['messages'] = array();
    }

    if (!isset($_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type] = array();
    }

    $_SESSION['messages'][$type][] = $message;
  }

  // messages not set when DB connection fails
  return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
}
Login or register to post comments