Page Chapter 2. Writing a Module, Page 13
I've just purchased the Pro Dupal book and installed Drupal Core 6.0. I had trouble getting the sample code on this page — function annotate_menu() — to work in 6.0. The error appeared when I clicked the Enable checkbox for the Annotate module in admin/build/modules.
P.S. Is this typical with changes in major Drupal versions? Should I perhaps work through the book using an earlier version of Drupal?
I had a go at changing the code to something that appears to, but may not in fact, actually work.
I got the function to work in the way described on the lower part of page 15 by changing the code to the following:
/**
* Implementation of hook_menu().
*/
function annotate_menu(){
$items = array();
if (!$may_cache) {
$items['admin/settings/annotate'] = array(
'title' => 'Annotation settings',
'description' => t('Change how annotations behave.'),
'page callback' => 'drupal_get_form',
'page arguments' => array('annotate_admin_settings'),
'access callback' => user_access('administer site configuration')
);
}
return $items;
}
The error message is:
warning: Missing argument 1 for annotate_menu() in /Applications/MAMP/htdocs/drupal/sites/all/modules/annotate/annotate.module on line 14.
Having a look through the Drupal API site led me to what appears to be a revision to the hook_menu() function. The changes seem to be the source of the error.
