Subtle hook_help() behavior in Drupal 5

Drupal 5’s system_get_module_admin_tasks() function attempts to ferret out any administrator pages that a given module provides, and is used to add them to each module’s section on the admin/by-module screen. If you provide admin help in your implementation of hook_help() it will also automatically display links to those administrator pages at the bottom of the admin/help/mymodule page (where mymodule is the name of your hypothetical module.)

Typically you would allow the menu items for those administrator pages to be cached:

<?php
/** A typical implementation of hook_menu(): */
function mymodule_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/mymodule',
'access' => user_access('access administration pages'),
'callback' => 'mymodule_admin_form'
);
}
else {
//Dynamic, non-cached menu items here
}

return $items;
}
?>

However, if you’re following the common practice of disabling caching for all of your menu items during module development, you’ll find that those automatic administrator page links don’t get generated. This makes sense once you realize that system_get_module_admin_tasks() only looks at cached menu items, but it’s the sort of subtle behavior that you wouldn’t necessarily know about without digging into the Drupal core, and might mistake for some kind of bug. When in doubt, the Drupal online API Documentation is your friend!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p><div> <br><img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.