This site is archived.
Skip to Content

Make a Module: A Hands-on Intro to Module Development

Your session in a few words: 
Learn to build Drupal 6 modules
September 3, 2009 - 13:40 - 14:30
From zero to hero
Session Type: 
Level of expertise: 

Interested in learning how to develop a custom Drupal module? This is a practical session designed to introduce you to module development.

Get hands-on. Bring your laptop and build your own module as we go. (Of course, you're welcome to just listen.)

We will cover:

  • Basic module architecture
  • .info files and .module files
  • Using hooks
  • Using existing Drupal APIs
  • Finding documentation
  • Debugging
  • Installing and uninstalling

By the end of this session, we will have created a functional module.


  • Some Drupal knowledge
  • Some PHP knowledge

If you want to write your own module as you go, you will need a laptop with...

  • A text editor or PHP IDE.
  • A Drupal install that you can access easily. I suggest a local copy running on your laptop.

The code from the presentation

In the presentation, I showed a .info file and a .module file. Here they are.


name = Paris
;package = paris
description = Example of how to build modules.
core = 6.x
php = 5.2
;dependencies[] = autoload

Update: To see the PHP code with syntax highlighting, see this DrupalBin entry:


// $Id$

* The main file for paris.
* @file

* Implementation of hook_help().
function paris_help($path, $args) {
if ($path == 'admin/help#paris') {
return t('This is an %foo example !another module.',
array('%foo' => 'extra-cool', '!another' => 'test'));

* Implementation of hook_block().
function paris_block($op = 'list', $delta = 0, $edit = NULL) {
switch ($op) {
case 'list':
// Declare names of deltas: $blocks['delta'] = array()
$blocks['paris_block'] = array(
'info' => t('Paris Block'),
$blocks['paris_block2'] = array(
'info' => t('Paris Block2'),
return $blocks;
case 'view':
// Create content. Usually, this will use $delta.
if($delta == 'paris_block') {
$block['subject'] = t('Subject');
$block['content'] = t('Op: %op, Delta: %delta',
array('%op' => $op, '%delta' => $delta));
elseif ($delta == 'paris_block2') {
$block['subject'] = t('Kittens are cute');
$block['content'] = t('Hi');

return $block;

For a much more elaborate example of the block code, you can take a look at the book Learning Durpal 6 Module Development.

could not get Paris module to work

Hi Matt, thank you for the files you used in class.
I installed them on my local machine version of Drupal and they were not recognized.
I have successfully installed several other modules in the >sites>all folder but for some reason the Paris module never shows up in the module list on my admin page.

I am running a macbook unibody with OS X with no special tweaks.

Any ideas of simple things that could cause this problem?