function nicemessages_set_messages in Nice messages 7
Same name and namespace in other branches
- 7.2 nicemessages.module \nicemessages_set_messages()
Save messages to js settings.
@TODO moving 'position' setting from line 118 up to foreach line 108 here and from form/global in line 147 down to foreach form/type in line 158 for having individual position for each message type @TODO corresponding changes in js file needed
1 call to nicemessages_set_messages()
- nicemessages_preprocess_page in ./
nicemessages.module - Implements hook_preprocess_page().
File
- ./
nicemessages.module, line 139 - Nicemessages module
Code
function nicemessages_set_messages() {
$items = array();
foreach (drupal_get_messages() as $type => $messages) {
foreach ($messages as $key => $message) {
$item = array(
'type' => $type,
'content' => $message,
'life' => variable_get('nicemessages_' . $type . '_life', '3') * 1000,
'glue' => variable_get('nicemessages_' . $type . '_glue', 'after'),
'speed' => variable_get('nicemessages_' . $type . '_speed', 'normal'),
);
$items[] = $item;
}
}
$settings = array(
'position' => variable_get('nicemessages_position', 'top-right'),
'items' => $items,
);
drupal_alter('nicemessages', $settings);
drupal_add_js(array(
'nicemessages' => $settings,
), 'setting');
}