Where can I find a skeleton module to start developing with
marcosscriven - October 14, 2008 - 21:18
Hi there
I am considering using Drupal, but before doing so I want to get an idea of how easy it is to develop modules.
As a test, I'd like an empty/hello world module I can just use as a base, or something like that.
Any ideas?
Thanks
Marcos

Module developer's guide
http://drupal.org/node/508
It's kind of impossible to
It's kind of impossible to give you a "skeleton module" like this because, strictly speaking, none of the hooks (the functions in your module that Drupal will call in order to interact with it) modules can use are mandatory. For example, a module which displayed "Hello, world!" would probably use hook_menu() to, for example, tell the system it wants to display something when the user goes to http://example.com/hello , but other types of modules, such as input filters (which act upon and transform entered text), probably won't use hook_menu() since they don't need to display a page themselves.
Your best bet might be to find a module which does something similar to what you want your module to do and see how it works.
And, of course, Pro Drupal Development is invaluable for first-time Drupal developers.
api.drupal.org
api.drupal.org has extensive documentation, including these examples:
Also ...
Also worth mentioning: Komodo Edit (which I highly recommend) has built-in tooltips and code snippets for Drupal. Here is the example skeleton module that Komodo provides. I believe it's for Drupal 5:
<?php
// \$Id\$
/**
* Implementation of hook_perm
*/
function «example»_perm() {
return array(
'«example permission»',
);
}
/**
* Implementation of hook_menu
*/
function «example»_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/«example»',
'title' => t('«Example»'),
'callback' => 'drupal_get_form',
'callback arguments' => array('«example»_admin_form'),
'access' => user_access('administer site configuration'),
);
}
return $items;
}
/**
* Menu callback - Admin settings form.
*/
function «example»_admin_form() {
$form = array();
return system_settings_form($form);
}
/**
* Implementation of hook_form_alter
*/
function «example»_form_alter($form_id, &$form) {
switch ($form_id) {
// Alter node edit form
case $form['type']['#value'] .'_node_form':
break;
}
}
/**
* Implementation of hook_nodeapi
*/
function «example»_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'delete':
break;
case 'insert':
break;
case 'load':
break;
case 'submit':
break;
case 'update':
break;
case 'view':
break;
}
}
?>
Wow - impressive
Wow - impressive feedback!
Thanks for all the suggestions, will take a look. Of course the fact that there's obviously such a good community is a big plus.
Marcos
This should help...
I actually was tired of writing the same code everytime I wanted to start a module. I wrote a quick app (running live off my site and available for download) that generates a skeleton module for you. All you need to do is fill out a form and it will take care of the rest to get you started. I hope you get to check it out and if you think its worth while then by all means submit some feedback on it.
http://www.dueyesterday.net/node/26
http://modgen.dueyesterday.net
dueyesterday.net - Documentation for the masses
Module Builder module
Also worth looking at http://drupal.org/project/module_builder
module basics
I found this page really helpful for understanding the basics of creating a module:
http://geeksandgod.com/tutorials/computers/cms/drupal/creating-simple-dr...
module basics
I found this page really helpful for understanding the basics of creating a module:
http://geeksandgod.com/tutorials/computers/cms/drupal/creating-simple-dr...