I'm playing with a custom module in Drupal, but it gives me the following two warnings:
Warning: Invalid argument supplied for foreach() in menu_unserialize() (line 377 of /site/includes/menu.inc).
Warning: Invalid argument supplied for foreach() in menu_unserialize() (line 377 of /site/includes/menu.inc).
Here is the module's code:
<?php
function homepage_coords_menu(){
return array(//$items
'homepage_coords/%node/%/%' => array(
'page callback' => 'homepage_coords_ajax_callback',
'page arguments' => array(1,2,3),
'access arguments' => TRUE,
'type' => MENU_CALLBACK,
)
);
}
function homepage_coords_ajax_callback($nid=0,$x=0,$y=0){
return 'nid:'.$nid.' x:'.$x.' y:'.$y;
}
?>
What can I do to fix these warnings?
Also any effeciency improvements would be appreciated :)
To turn on the “Error Messages to Display”, go to the Administration menu, then go into Configuration > Development > Logging and errors (/admin/config/development/logging).
You can show all errors by adding a few lines to your local testing site's settings. php: error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); In addition, navigate to Administration→ Configuration→ Development → logging and errors and select "All messages".
To view entries in Drupal's own internal log system (the watchdog database table), go to http://example.com/admin/reports/dblog. These can include Drupal-specific errors as well as general PHP or MySQL errors that have been thrown. Use the watchdog() function to add an entry to this log from your own custom module.
To allow access to all, you need to set 'access callback' to TRUE, not 'access arguments'. Also, are you really sure that you don't have an access definitions for that page?
Your coding style is untypical, this hard to read when you are used to the default way of doing it. See node_menu() for examples. I initially thought you were doing it in the old Drupal 5 way.
It looks like the first argument is a node, I suggest you use %node then, the menu system will then automatically load the node and only call your page callback if the argument is a valid node id. key would look like this then: "homepage_cords/%node/%/%".
I ran into this error because I was passing a string to "page arguments" instead of an array.
$items['page arguments'] = array('module_my_form');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With