Best Practice notes

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Drupal Coding standards

Follow the [Drupal coding standards] (http://drupal.org/coding-standards). The coding standards provide information on code syntax, white space in code, and currently more development detail than this wiki page.

Required Files

When a module gets too long it is wisest to break up a custom module into the following files:

  • MYMODULE.info - Module declaration file.
  • MYMODULE.module - for Drupal hooks like hook_menu, hook_forms, etc.

Additional Files

  • MYMODULE.install - when your module has custom install & uninstall requirements and/or integration.
  • *.tpl.php - a PHPTemplate your module provides to the Drupal theme layer and is declared in your *.module file.

When a module gets too long it is wisest to break up a custom module into the following files:

  • MYMODULE.pages.inc - for pages your module renders.
  • MYMODULE.admin.inc - for administration/setting pages & forms

Folders

  • MYMODULE/ - your module folder; all files (usually) go in this folder.
  • MYMODULE/includes - when your module has common includes that seem best to organize them into their own folder.
  • MYMODULE/templates - when your module has a lot of templates then a folder may help keep them organized.
  • MYMODULE/tests - for simpletest files (unit testing); required for Drupal 7 modules; recommended for Drupal 6 modules)..

Please add more notes & tips