You are here

function hook_uc_message in Ubercart 5

Same name and namespace in other branches
  1. 6.2 docs/hooks.php \hook_uc_message()
  2. 7.3 uc_store/uc_store.api.php \hook_uc_message()

Convenience function to display large blocks of text in several places.

There are many instances where Ubercart modules have configurable blocks of text. These usually come with default messages, like e-mail templates for new orders. Because of the way default values are normally set, you're then stuck having to copy and paste a large chunk of text in at least two different places in the module (when you're wanting to use the variable or to display the settings form with the default value). To cut down code clutter, this hook was introduced. It lets you put your messages in one place and use the function uc_get_message() to retrieve the default value at any time (and from any module).

The function is very simple, expecting no arguments and returning a basic associative array with keys being message IDs and their values being the default message. When you call uc_get_message(), use the message ID you set here to refer to the message you want.

Note: When using t(), you must not pass it a concatenated string! So our example has no line breaks in the message even though it is much wider than 80 characters. Using concatenation breaks translation.

Return value

An array of messages.

5 functions implement hook_uc_message()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_cart_uc_message in uc_cart/uc_cart.module
Implementation of hook_uc_message().
uc_file_uc_message in uc_file/uc_file.module
Implementation of hook_uc_message().
uc_notify_uc_message in uc_notify/uc_notify.module
Implementation of hook_uc_message().
uc_roles_uc_message in uc_roles/uc_roles.module
Implementation of hook_uc_message().
uc_stock_uc_message in uc_stock/uc_stock.module
Implementation of hook_uc_message().
1 invocation of hook_uc_message()
uc_get_message in uc_store/uc_store.module
Return the default message for a configurable message.

File

docs/hooks.php, line 1077
These are the hooks that are invoked by the Übercart core.

Code

function hook_uc_message() {
  $messages['configurable_message_example'] = t('This block of text represents a configurable message such as a set of instructions or an e-mail template.  Using hook_uc_message to handle the default values for these is so easy even your grandma can do it!');
  return $messages;
}