You are here

function hook_uc_message in Ubercart 7.3

Same name and namespace in other branches
  1. 5 docs/hooks.php \hook_uc_message()
  2. 6.2 docs/hooks.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.

4 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
Implements hook_uc_message().
uc_order_uc_message in uc_order/uc_order.module
Implements hook_uc_message().
uc_roles_uc_message in uc_roles/uc_roles.module
Implements hook_uc_message().
uc_stock_uc_message in uc_stock/uc_stock.module
Implements hook_uc_message().
1 invocation of hook_uc_message()
uc_get_message in uc_store/uc_store.module
Returns the default message for a configurable message.

File

uc_store/uc_store.api.php, line 96
Hooks provided by the Store module.

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;
}