Book Image

Learning Drupal 6 Module Development

Book Image

Learning Drupal 6 Module Development

Overview of this book

Table of Contents (14 chapters)
Learning Drupal 6 Module Development
Credits
About the Author
About the Reviewers
Preface

Finishing Touches: hook_help()


We now have a functioning module. However, there is one last thing that a good Drupal module should have. Modules should implement the hook_help() function to provide help text for module users.

Our module is not very complex. Our help hook won't be, either:

/**
* Implementation of hook_help()
*/
function goodreads_help($path, $arg) {
if ($path == 'admin/help#goodreads') {
$txt = 'The Goodreads module uses the !goodreads_url XML '
.'API to retrieve a list of books and display it as block '
.'content.';
$link = l('Goodreads.com', 'http://www.goodreads.com');
$replace = array(
'!goodreads_url' => $link
);
return '<p>'. t($txt, $replace) .'</p>';
}
}

The hook_help() function gets two parameters: $path, which contains a URI fragment indicating what help page was called, and $arg, which might contain extra information.

In a complex instance of hook_help(), you might use a switch statement on the $path, returning different help text for each possible...