I attended Zivtech's Drupal Module Development two-day training class, May 27, and 28th in NYC.
I'm glad that I had been developing Drupal module development at work for a few months previous to this class, or I would have been quite lost.
Of course, as I expected, I am picking up a few things.
General
Storing State Directly in $form Variable
I 've been doing multi-step forms, which requires saving state between form submissions. I had been messing around with creating hidden form fields (standard fare for straight PHP, or CGIs). I also have been experimenting with $form_state[ 'storage' ];. But I didn't realize you can store whatever you want (including objects) as the value of a hashed array index of the form variable (if that's what you call it):
function my_module_some_form() {
// form array definition etc.
$form['#the-user'] = $user;
}
Modules
Coder Module
This module helps with coding style, kind of like a lint for Drupal. It also helps with updating your code to a new version of Drupal core.
Devel Execute PHP Code
As part of the devel module, this gives you a PHP console in a textarea that allows you to execute arbitrary PHP code in the Drupal context. You have to enable the development block in the block-admin page to use this.
String Override Module
A module at drupal.org/project/stringoverrides, which will globally replace a string passed through the t() function to another string.
Drupal Functions
hook_form_NODE_ID_alter()
You implement hook_form_alter in your module to alter another module's form. By default this hook will get fired on all form renders, for all modules. Because of this, you would need to have a messy conditional that checks if we are altering the correct form. Instead, use hook_form_theid_of_your_form_alter(). That way you avoid that conditional.
hook_update()
Just never got around to exploring this. This allows you to update your module, change the schema etc. when you run update.php. You use it like this:
function mymodule_update_6000() {
// code
}
You then increment the number to indicate the updates to show on the module update page when runnning update.php. The next update would be.
function mymodule_update_6001() {
//code
}
hook_user_access()
I guess I should have know this, but I haven't worked much with permissions at this point. This returns TRUE or FALSE depending on if the current user has access or not.
t() Placeholders
Passing strings to t(), allows the Drupal framework to localize the string. It's also good to pass strings to t(), because you can do global string replaces using String Override module. You can stick variables into t(), and have them translated by doing something like this:
t('The address !email already subscribed to this node', array( '!email'=> $email ) );