39. function my_message($name) {
return “This is your message, $name!”;
}
function my_message($name) {
$values = array(‘%name’ => $name);
$message = ‘This is your message, %name!’;
return t($message, $values);
}
42. /**
* Prepares a structured form array by adding required elements,
* executing any hook_form_alter functions, and optionally
* inserting a validation token to prevent tampering.
*
* @param $form_id
* A unique string identifying the form for validation,
* submission, theming, and hook_form_alter functions.
* @param $form
* An associative array containing the structure of the form.
* @param $form_state
* A keyed array containing the current state of the form.
* Passed in here so that hook_form_alter() calls can use it,
* as well.
*/
function drupal_prepare_form($form_id, &$form, &$form_state) {
// Actual codes goes here…
}
71. function my_module_stuff($reset = FALSE) {
static $stuff;
if (!isset($stuff) || $reset) {
if (!$reset && ($cache = cache_get('my_stuff'))) {
$stuff = $cache->data;
make your
}
else {
own cache
// Do your expensive calculations here,
// and populate $my_data with stuff..
cache_set('my_stuff', $stuff);
}
}
return $stuff;
}
wrote forms in straight html
duplicated workflow code
duplicated security code (hopefully)
hack, hack, hack to customize
build arrays to describe the form
use standard workflow (drupal_get_form())
security is automatic
THEN render to HTML.