Community Documentation

02. Telling Drupal about your module

Last updated March 1, 2010. Created by kitt on May 13, 2005.
Edited by JohnNoc, esmerel, pwolanin, sepeck. Log in to edit this page.

For Drupal 5.x, see: http://drupal.org/node/64279#info and http://drupal.org/node/64279#comment-150594

The first function we'll write will tell Drupal information about your module: its name and description. The hook name for this function is 'help', so start with the onthisdate_help function:

<?php
function onthisdate_help($section='') {

}
?>

The $section variable provides context for the help: where in Drupal or the module are we looking for help. The recommended way to process this variable is with a switch statement. You'll see this code pattern in other modules.

<?php
/**
* Display help and module information
* @param section which section of the site we're displaying help
* @return help text for section
*/
function onthisdate_help($section='') {

 
$output = '';

  switch (
$section) {
    case
"admin/modules#description":
     
$output = t("Displays links to nodes created on this date");
      break;
  }

  return
$output;
}
// function onthisdate_help
?>

The admin/modules#description case is used by the Drupal core as the module description on the modules administration page (/admin/modules or ?q=admin/modules).

You will eventually want to add other cases to this switch statement to provide real help messages to the user. In particular, output for "admin/help#onthisdate" will display on the main help page accessed by the admin/help URL for this module (/admin/help or ?q=admin/help).

More information about the help hook:

Download the code so far, (4.7 version) renaming to onthisdate.module before saving in your Drupal installation.

Page status

About this page

Drupal version
Drupal 4.6.x, Drupal 4.7.x

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here