You are hereBlogs / Jeff Schuler's blog / Drupal Module Development Kickstart (DrupalCon 2009 notes)

Drupal Module Development Kickstart (DrupalCon 2009 notes)


Posted by Jeff Schuler - on 04 March 2009

Developing Modules kick-Start
Gábor Hojtsy and Peter Wolanin

This is about developing modules, but if you can find a module that's already out there and being developed, use it!

if you can avoid custom code or modifying, build the right way and use existing code when available

Change almost anything without hacking core.

What is a module?

  • .module + .info text files
  • Implements hooks, Drupal exposed interfaces to plug into the system

replace "hook" keyword with module name

  • to implement hook_perm(), write modulename_perm()

module directory goes in:

  • sites/all/modules/modulename  (or)
  • sites/domainname/modules/modulename

example: how to allow admins to delete something faster

  • add a 'delete this post' button to a node's menu
  • hook_link()

example: focused search

  • add a radio button to search panel to search all content or search a particular content type only
  • use hook_form_alter()
  • gives modules a chance to change forms before they're presented

example: editing the Contact form

example: module from scratch: whiteboard (from Szeged)

  • hook_menu()
    • make page callback to custom function (not a hook)
    • access arguments
  • but avoid this! use Views

module_invoke_all()

  • "if any other module is interested, take action now"

References