2. Who is this bozo? Adam A. Gregory Drupal Developer for 4 years PHP developer for 8+ years Contribute and maintains modules on Drupal.org Currently work as a freelance Drupal ninja. Worked on Drupal sites large and small. http://AdamAGregory.com
3. Why create a module? New functionality Override existing functionality Forms Nodes Users Search Theming Combination of the two Almost every site needs a custom module
4. Before you start Is there an existing module Drupal.org (http://drupal.org/project/Modules/name) IRC Mailing list (development@drupal.org) What you need PHP/SQL/HTML/CSS skill IDE Test site Drupal API (http://api.lullabot.com)
6. .info File Where Drupal gathers all the knowledge about your module Contains module name, decsription, group, version, requirements and dependencies
7. ;$Id: $ name=Custom Publishing Options description=Adds the ability to add Custom publishing options to the node Add/Edit form. core=6.x package=Other
8. .module File Must have the same name is .info file Contains the PHP code for your module All core hooks must be included in this file to work Should be kept small as it is loaded on every page load Dynamically loading inc files either via hook_menu or by loading them when a hook is called
9.
10. .install File Only needed if you module makes ANY sort of DB changes Invokes hook_install, hook_uninstall, hook_update_##, and hook_schema
12. Theres a hook for that Drupal works off a hooking system similar to an Observer pattern. Main hooks most modules use Hook_menu Hook_help Hook_form_alter Hook_user Hook_nodeapi API site can help you find other hooks
13. Organizing Your Code .info and .module are the only required files for a module Keep html/css/js in separate files and not hard coded into .module files Functions for specific pages should moved into .inc files & loaded dynamically Any calls to module files(.inc, .css, .js) should use drupal_get_path($type, $name) for css/js or module_load_include for php
14. Organizing your code cont. Remember you shouldn’t hard code things like internal links, file paths, etc as you don’t know what sites will use your module and how. Keep your code dynamic and reusable Keep file sizes small and load them when needed for better performance
15. Finishing Up Load you module into a test site and enable it. Test! Test! Test! Stuff won’t work, you’ll have errors, and things will go crazy DON’T PANIC! It happens, take your time and debug the issues. Use Google, the API, IRC, Forums, Lists, Groups, etc. that are available for help.
16. A few words about security? Never, ever under any circumstances trust User Input. Drupal provides many functions and resources to properly secure your code. Visit http://drupal.org/writing-secure-code for more info.
17. Contributing Back http://drupal.org/contribute If you have created something that will be widely useful, or al least you think it will be, you may want to get it listed on Drupal.org, but how? The process can be painful, long, and hit and miss. Remember the D.o maintainers are volunteers. Requires knowledge of CVS(Blah!)