Creating a Drupal Module — Part 1: File and Directory Layout
The directory layout of your module can be as simple as two files. For the rest of this tutorial, I will use the module name testmod. Be sure to pick a name that you like, because it will be present in the code and visible the end user.
First, create a folder with the name of the module, in our case testmod. Next make testmod.info and testmod.module files.
testmod
testmod.info
testmod.module
Place the testmod directory in the non-core module directory. This will usually be under sites/all/modules/ for Drupal 6.x.
The .info File (jump to part 2)
The .info file contains the descriptive text shown in Drupal's module administration page (Administer > Site building > Modules). The contents are very simple: name, description, and Drupal compatibility version. In the next section, we will fill this information out.
The .module File (jump to part 3)
The .module file, of course, holds the code for your module. This code is written in PHP. You may, of course, link to external files in your module directory. Since our example module is a simple one, we will keep all code in the .module file.
- Add new comment
- 1089 reads