Creating the module's files and folder(s)

Note: from here forward, I'll assume that

  • you're using Windows (as opposed to Mac or Linux).
  • you're using Notepad++ (as described on the previous page).
  • you want to write a module that will create a new "incident" node type, meaning once the module is installed, when your users click "Create Content" they'll see the option to create a new Incident (or Incident Report, depending on how we decide we want the form to appear).
    • Either way, the name of the module will be incident.

Here we go.

First, create a new folder on your desktop and name the folder incident.

  • Note: when writing a Drupal module, only use lowercase letters and underscores for the module's name -- no numbers, hyphens, dashes, slashes, periods, dots, commas, tildes, ampersands, etc. In fact, if possible, avoid the underscores too.

Anyway, you should now have a new, empty folder on your desktop called incident. Moving on.

Next, open Notepad++ and on the first line, type this:

; $Id$

Below that, add the following:

name = Incident Report
description = Allows users to create and submit incident reports.
core = 6.x

Now:

  1. Click File » Save
    • Make sure you're saving it in the incident folder you just created.
  2. Next to File name, type in incident.info
  3. Click Save

You should now have a file named incident.info inside a folder named incident, and the file itself (incident.info) should look like this:

; $Id$
name = Incident Report
description = Allows users to create and submit incident reports.
core = 6.x

That does it for step one. At minimum, your module will have two files:

  • A .info file (already did that part), and
  • A .module file

... Which brings us to the .module file. The first part is a partial repeat of what we just did, but it's equally necessary:

  • Open Notepad++ (or if it's already open, create a new file: File » New)
  • Before you do any writing this time, immediately click File » Save (this is for convenience purposes only, but it's well worth it).
  • Again, make sure you're saving it in the incident folder you already created.
  • Next to File name, type in incident.module
  • Click Save

You should now have a file named incident.module, along with your incident.info file, both inside the same folder (whose name is incident). Here's a little "tree" diagram:

» My Desktop

⌊» incident

⌊» incident.info

⌊» incident.module

NOW, with the incident.module file still open, we can start writing the module itself.