Published on Proof (http://www.proofgroup.com)
Subtle hook_help() behavior in Drupal 5
By andy
Created 02/25/2008 - 19:56

Drupal 5’s system_get_module_admin_tasks() [1] 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() [2] 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 [3] is your friend!

© 2008 The Proof Group LLC
  • Terms of Use
  • Privacy Statement

Source URL: http://www.proofgroup.com/blog/2008/feb/subtle_hook_help_behavior_drupal_5

Links:
[1] http://api.drupal.org/api/function/system_get_module_admin_tasks/5
[2] http://api.drupal.org/api/function/hook_help/5
[3] http://api.drupal.org/api