I want to briefly walk through making a 'skeleton' module for Drupal 6x.
1. You want to go ahead and create a folder named "custom" in /sites/default/modules/
2. Create a folder named "skeleton", the folder name will be the module name.
3. You should make 4 files in the skeleton folder, skeleton.info, skeleton.module, skeleton.inc, and skeleton_example.tpl.php
4. The .info file describes the module to drupal, the .module file is where your hooks will go, and the .inc file is a place to put any extra helper functions.
skeleton.info
; $Id$ name = skeleton description = Empty starter module. core = 6.x
skeleton.inc
<?php /* Put any helper functions or other stuff you want in here */
skeleton_example.tpl.php
<div id="skeleton_example"> <b>Skeleton Example Template File</b> </div>
And finally, the skeleton.module file
<?php
// $Id: skeleton.module
/**
* @file
* Skeleton Module File.
*/
//pull in our include file
module_load_include('inc', 'skeleton');
/* This is where you can start calling in the drupal hooks that make up your module
some example hooks like hook_user, hook_menu, hook_perm are listed below
*/
//module permissions
function skeleton_perm() {
return array('skeleton module permission');
}
//lets get some sweet sweet menu action going
function skeleton_menu() {
$items['skeleton/example'] = array(
'title' => 'Skeleton Module Hook Menu Example',
'description' => t('Skeleton Module Hook Menu Example'),
'page callback' => 'skeleton_example', //
'access callback' => 'user_access',
'access arguments' => array('skeleton module permission'), // or use hook_perm() to make your own
'type' => MENU_CALLBACK,
);
return $items;
}
//hook_theme
function skeleton_theme($existing, $type, $theme, $path) {
return array(
'skeleton_example' => array(
'arguments' => array('options' => NULL),
'template' => 'skeleton_example',
),
);
}
You should now be able to enable the module, and make sure to assign the permission we created to whatever user you are. Then navigate to the /skeleton/example page and you should see what we put in the template file. You can download the full skeleton module example HERE.