typo – “signup – let’s”
usually don’t have to start from scratch, even if goal is to do something complex! often adding to or building on existing module.
will encourage you not to write a module if you don’t have to.
hooks – extend existing action.
I’m performing a particular action – does anyone have anything to say about it? I’m getting up to get napkins, does anybody want anything else? Yes, please get straws. I’m presenting a form to the user – please add a checkbox to that form.
hook_form_alter
hook_user
hook_nodeapi
hook_mail
form API – an array that translates to html. I like arrays.
includes some automatic security protection.
sample project American Society for Delicious Foods (ASDF) – redirect user to appropriate category page after submitting a recipe.
hook_form_alter & dpm (a Devel function) – easily print any variable to the screen, instead of printr()!
kitty!
.info – tells Drupal that module exists – .module – contains main module code.
[note that I think all this is all in D7, but apparently concepts are the same]
find out about the node that was submitted – in Devel tab, find the
API site – looking up hook_form_alter – copy/paste function name & options
replace “hook” with the module’s name
devel will show a list of all the form IDs on the page, which you can use in the code.
really nice that he paused and asked if anybody was lost…and a few people were lost, and he’s being really good about addressing them.
using the dpm() function in the new module to print out information about the form.
find the save button in the form array. node_form_submit – that’s the function that gets called. add a second function after that one.
dpm($form['actions']['submit'], etc) – and then just see the part of the form that you want to understand.
but how to know what to do? – find example of how to do stuff when submitting a form.
when you create a function that does something, you add it to the array.
group debugging! possibly a typo.
shows that another function exists, and then the function runs at that point in the process.
form state -> values -> field_type_recipe, etc., etc.
interesting gotcha re: PHP constant LANGUAGE_NONE (?)
form_state[redirect] and set the path, using the term id that was extracted.
yay, it worked!
that’s pretty cool, actually.
helpful: variable_get, variable_set, user_access (related to permissions), t() – for translating interface text, makes it possible for others to translate your module,
common pattern: implement more or one hooks, use drupal API helper function, then do something custom.
func_get_args – see what arguments are passed to a function; helpful to compare what args get passed to successful operation vs unsuccessful one.
debug_backtrace – useful for WTF moments.
ezrabg on twitter.
I might be able to rewrite my multisearch module and even know WTF I’m doing.
example module!
maybe now I have a hope of adopting Ads Views.