Community Documentation

How to build up a _help hook

Last updated February 19, 2008. Created by puregin on May 30, 2005.
Edited by ax. Log in to edit this page.

The following template can be used to build a _help hook.

<?php
function <modulename>_help($section){
 
$output = "";

  switch (
$section) {

  }
  return
$output;
}
?>

In the template replace modulename with the name of your module.

If you want to add help text to the overall administrative section. (admin/help) stick this inside the switch:

<?php
   
case 'admin/help#<modulename>':
     
$output = t('The text you want displayed');
      break;
?>

If you also want this same text displayed for an individual help link in your menu area. You have this kind of tree:

  + Administration
  |
  -> Your area
  |  |
  |  -> Your configuration
  |  -> help
  |
  -> Overall admin help.

Change the function line to this:

<?php
function <modulename>_help($section = 'admin/help#<modlename>') {
?>

Now that you have the template started place a case statement in for any URL you want a "context sesitive" help message in the admin section. An example, you have a page that individually configures your module, it is at admin/system/modules/, you want to add some text to the top help area.

<?php
   
case 'admin/system/modules/<modulename>':
     
$output = t('Your new help text');
      break;
?>

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.