I'm new to module development and am trying to follow through some examples from pro developer book. I have the menu items showing up but once I click the link I get a white page without the form and the following error message.

"warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'system_settings_overview' not found or invalid function name in /home/quickstart/websites/modules.dev/includes/menu.inc on line 348."

Seems a callback error but I'm not sure where the problem lays. Can anyone see the problem or better yet give me some pointers on debugging. I've looked at hook_menu on api.drupal.org but haven't found an answer. There are no other modules running on the site.

my function in annotate.module

function annotate_menu() {
$items['admin/settings/annotate'] = array (
'title'=>'Annotation Settings',
'description' => 'Change how annotations behave.',
'page_callback' => 'drupal_get_form',
'page arguments' => array('annotate_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'annotate.admin.inc'
);
return$items;
}

annotate.admin.inc

function annotate_admin_settings() {
// Get an array of node types with internal names as keys and
// "friendly names" as values. E.g.,
// array('page' => 'Page', 'story' => 'Story')
$options = node_get_types('names');
$form['annotate_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Users may annotate these content types'),
'#options' => $options,
'#default_value' => variable_get('annotate_node_types', array('page')),
'#description' => t('A text field will be available on these content types to
make user-specific notes.'),
);
return system_settings_form($form);
}

cheers Vmpwraith

Comments

jaypan’s picture

You have to add the 'file path' in your hook_menu() definition. It's probably there in the book, you just missed it.

Contact me to contract me for D7 -> D10/11 migrations.

JasonMoreland’s picture

adding

'file path' => drupal_get_path('module', 'system'),

at the end seemed to work. It also seems that it only needs to be called once then any subsequent menu items using the first parent menu didn't need it.

function mymodulemenu_menu() {
$items['admin/mymodulemenu'] = array(
'title' => 'mymodulemenu Modules',
'description' => 'Adjust mymodulemenu module settings.',
'position' => 'right',
'weight' => -5,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('administer site configuration'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);

return $items;
}

function annotate_menu() {
$items['admin/mymodulemenu/annotate/settings'] = array(
'title' => 'Annotation settings',
'description' => 'Change how annotations behave.',
'page callback' => 'drupal_get_form',
'page arguments' => array('annotate_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'annotate.admin.inc',
);
return $items;
}
npoleon06’s picture

I tired adding the 'file path' but I must have done it wrong because it's still not working. I need a little more explanation.
I am doing ths exact same example from the Pro Drupal Development book. No..the file path is not in the book.

My set up is on a portable hard drive. With the following url

http://localhost:8080/drupal/

I have a folder called

E:\www\drupal\sites\all\modules\custom\annotate

That has 3 files the annotate.INFO, annotate.MODULE and a annotate.ADMIN.INC file.

Now if I read this error log correctly

Details
Type php
Date Thursday, March 31, 2011 - 09:23
User mf4good
Location http://localhost:8080/drupal/admin/settings/annotate
Referrer http://localhost:8080/drupal/
Message call_user_func_array() expects parameter 1 to be a valid callback, function 'system_settings_overview' not found or invalid function name in E:\www\drupal\includes\menu.inc on line 348.
Severity error
Hostname 127.0.0.1
Operations

It's looking for this system_settings_overview function and can't find it. So I did a search for it and found it here:
www/drupal/module/system/system.admin.inc

So I added
'file path' => drupal_get_path('module', 'system'),

like so

function annotate_menu() {
$items['admin/settings/annotate'] = array(
'title' => 'Annotation settings',
'description' => 'Change how annotations behave.',
'page calback' => 'drupal_get_form',
'page arguments' => array('annotate_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'annotate.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);

return $items;
}

But I am still getting the WSOD. What am I missing?

npoleon06’s picture

I went to the Drupalbook.com website. Downloaded the code (without any changes) and got the same error.

jaypan’s picture

A few points:

1) The error you are referring to doesn't appear to be for the menu item you have shown.
2) You spelled 'callback' wrong. This will cause you troubles.
3) You need to clear the cache after making ANY changes to hook_menu(). No changes will take effect until you have done this.
4) Your file path is wrong. The function you have created is a custom function in annotate.admin.inc. This file is NOT located in the system folder, it is in the same folder as your menu definition, therefore you should remove the 'file path' line. Then clear the cache :D

Contact me to contract me for D7 -> D10/11 migrations.

alexgreyhead’s picture

If the error still occurs, it's worth ensuring that any implementations of hook_menu use 'page callback' => '...' and NOT 'page_callback' - the underscore is wrong - this one's had two of us flummoxed for the last 30 minutes now!

aegagros’s picture

mate, it took you only 30 minutes... it took me the whole day today (with a short break for food) to figure out what was wrong with my module settings page registration, until I saw your post! It was an erroneous underscore all along... thumbs up for you and thank you!

Sk8erPeter’s picture

@alexharries: I can confirm that. I was happy to find what you wrote as I overlooked this mistake! Thanks a lot!

bensey’s picture

Yep, many hours here, brain exploding.
Damn that array and its lack of underscores..!
It's far too easy to treat them like function names...