Help text

Drupal modules can provide help text to users in the .info file, and by implementing hook_help(). A hook_help() implementation defines help text for the URLs your module provides (settings pages, editing forms, etc.), indexed by the path to the page. In addition, the special path 'admin/help#modulename' should be used to define an overview help page for each module.

Short Description

A short description of your module goes in the mymodule.info file, in element "description"; this description is displayed on the Modules administration screen, to tell a site administrator what your module does. The description should start with a verb and be relatively concise. Example (from the core node module in Drupal 7):

description = Allows content to be submitted to the site and displayed on pages.

Help text for your module's paths

Help text for individual paths in your module is generally fairly brief, as it is displayed either at the top of the page or in a block, depending on which version of Drupal you are running. Here is an example of an individual path's help text, from the Node Revisions screen in the Node module [this is part of the node_help() implementation of hook_help()]:

    case 'node/%/revisions':
      return '<p>' . t('The revisions let you track differences between multiple versions of your content.') . '</p>';

Overview help page for module

The overview help page for your module should follow a standard structure. It should begin with an "About" section (giving a brief overview of what the module does, starting with text like "The Foo module [verb]", and finishing with the link to the module's handbook page) and also contain a "Uses" section (giving details of module functionality, and links to the URLs where each specific functionality can be accessed). Capitalize the name of the module. Here is an example of an overview page from the Node module. First, the hook_help() section that defines the page:

    case 'admin/help#node':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Node module manages the creation, editing, deletion, settings, and display of all site content. For more information, see the online handbook entry for <a href="@node">Node module</a>.', array('@node' => 'http://drupal.org/handbook/modules/node')) . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Creating content') . '</dt>';
      $output .= '<dd>' . t('When new content is created, the Node module records basic information about the content, including the author, date of creation, and the <a href="@content-type">Content type</a>. It also manages the <em>publishing options</em>, which define whether or not the content is published, promoted to the front page of the site, and/or sticky at the top of content lists. Default settings can be configured for each <a href="@content-type">type of content</a> on your site.', array('@content-type' => url('admin/structure/types'))) . '</dd>';
      $output .= '<dt>' . t('Creating custom content types') . '</dt>';
      $output .= '<dd>' . t('The Node module gives users with the <em>Administer content types</em> permission the ability to <a href="@content-new">create new content types</a> in addition to the default ones already configured. Creating custom content types allows you the flexibility to add <a href="@field">fields</a> and configure default settings that suit the differing needs of various site content.', array('@content-new' => url('admin/structure/types/add'), '@field' => url('admin/help/field'))) . '</dd>';
      $output .= '<dt>' . t('Administering content') . '</dt>';
      $output .= '<dd>' . t('The <a href="@content">Content administration page</a> allows you to review and bulk manage your site content.', array('@content' => url('admin/content'))) . '</dd>';
      $output .= '<dt>' . t('Creating revisions') . '</dt>';
      $output .= '<dd>' . t('The Node module also enables you to create multiple versions of any content, and revert to older versions using the <em>Revision information</em> settings.') . '</dd>';
      $output .= '<dt>' . t('User permissions') . '</dt>';
      $output .= '<dd>' . t('The Node module makes a number of permissions available for each content type, which can be set by role on the <a href="@permissions">permissions page</a>.', array('@permissions' => url('admin/settings/permissions'))) . '</dd>';
      $output .= '</dl>';
      return $output;

This definition results in the following HTML:

<h3>About</h3>
<p>The Node module manages the creation, editing, deletion, settings, and display of all site content. For more information, see the online handbook entry for <a href="http://drupal.org/handbook/modules/node">Node module</a>.</p>
<h3>Uses</h3>
<dl>
<dt>Creating content</dt>
<dd>When new content is created, the Node module records basic information about the content, including the author, date of creation, and the <a href="@content-type">Content type</a>. It also manages the <em>publishing options</em>, which define whether or not the content is published, promoted to the front page of the site, and/or sticky at the top of content lists. Default settings can be configured for each <a href="admin/structure/types">type of content</a> on your site.</dd>
<dt>Creating custom content types</dt>
<dd>The Node module gives users with the <em>Administer content types</em> permission the ability to <a href="admin/structure/types/add">create new content types</a> in addition to the default ones already configured. Creating custom content types allows you the flexibility to add <a href="admin/help/field">fields</a> and configure default settings that suit the differing needs of various site content.</dd>
<dt>Administering content</dt>
<dd>The <a href="admin/content">Content administration page</a> allows you to review and bulk manage your site content.</dd>
<dt>Creating revisions</dt>
<dd>The Node module also enables you to create multiple versions of any content, and revert to older versions using the <em>Revision information</em> settings.</dd>
<dt>User permissions</dt>
<dd>The Node module makes a number of permissions available for each content type, which can be set by role on the <a href="admin/settings/permissions">permissions page</a>.
</dl>

That HTML is rendered like this:

About

The Node module manages the creation, editing, deletion, settings, and display of all site content. For more information, see the online handbook entry for Node module.

Uses

Creating content
When new content is created, the Node module records basic information about the content, including the author, date of creation, and the Content type. It also manages the publishing options, which define whether or not the content is published, promoted to the front page of the site, and/or sticky at the top of content lists. Default settings can be configured for each type of content on your site.
Creating custom content types
The Node module gives users with the Administer content types permission the ability to create new content types in addition to the default ones already configured. Creating custom content types allows you the flexibility to add fields and configure default settings that suit the differing needs of various site content.
Administering content
The Content administration page allows you to review and bulk manage your site content.
Creating revisions
The Node module also enables you to create multiple versions of any content, and revert to older versions using the Revision information settings.
User permissions
The Node module makes a number of permissions available for each content type, which can be set by role on the permissions page.

Heredoc?

manji51 - December 8, 2009 - 20:38

I am wondering why PHP Heredoc syntax wasn't used for the PHP code used to output the help page's HTML? I would think it'd increase readability. Is it because of the t() functions?

 
 

Drupal is a registered trademark of Dries Buytaert.