Hello DrupNewb Module
Submitted by larry on Thu, 11/29/2007 - 22:46.
When learning a new language or system I always like to write a simple "Hello World" program. Therefore, to learn about Drupal Modules I have written "hello_drupnewb".
README.txt
HELLO_DRUPNEWB MODULE
-------------
hello_drupnewb.module is a "Hello World" module for Drupal,
and is meant to be the simplest possible module I could build.
I used "Pro Drupal Development" by Van Dyk and Westgate
as well as a Drupal Forum Post (http://drupal.org/node/84658)
as references.
see hello_drupnewb run at: http://www.drupnewb.com/?q=hello_drupnewb
to install put files in a "hello_drupnewb" directory under
/sites/all/modules,
and turn on in admin at Administer >> Site Building >> Modules
Author:
Larry Truett
hello_drupnewb.info
; $Id$
name = Hello Drupnewb
description = "a hello world Drupal module."
hello_drupnewb.module
<?php
// $Id$
/**
* @file
* a hello world Drupal module
*
* the simplest possible module I could create
*/
/**
* Implementation of hook_menu().
*/
function hello_drupnewb_menu($may_cache) {
$items = array();
if (!$may_cache) {
$items[] = array(
'path' => 'hello_drupnewb',
'title' => t('Hello DrupNewb'),
'description' => t('Hello DrupNewb.'),
'callback' => 'hello_drupnewb_page',
'access' => TRUE,
'weight' => 10
);
}
return $items;
}
/**
* Implemenation of page.
*/
function hello_drupnewb_page() {
return 'Hello DrupNewb!
';
}
/**
* Implementation of help.
*/
function hello_drupnewb_help($section) {
switch ($section) {
case 'admin/help#hello_drupnewb':
return 'hello drupnewb help';
}
}
(note: the above module didn't show proper indenting with the <code> tag, but does with the <pre> tag.)
»
- larry's blog
- Login or register to post comments
