Friday, 29 October 2010

Drupal 6: Altering the help message for a particular URL

I noticed that on the "All Content" page, the help message is empty, but my theme still displays a big empty bubble, which looks like a bug. After doing some research I realised the help message on this page came from the node_help() function, and was returning just a space on purpose, as a not-null value meant that the little "more help" link would still be displayed.

SOLUTION
Implement the theme_help() hook in your theme's template.php. Note: replace THEME with your theme name.

function THEME_help() {
 $help = menu_get_active_help();
 if (arg(0)."/".arg(1)."/".arg(2)=="admin/content/node" && !arg(3))
 {
  $help = "<p>My help message.<p>".$help;
 }
 
 if ($help) return "<div class='help'>".$help."</div>";
 else return null;
}

This will work for the URL admin/content/node, but can easily be altered to work for any URL.

REFERENCES
http://stackoverflow.com/questions/1296106/drupal-6-hook-for-altering-help-field-in-a-form

1 comment: