Hello guys,
I guess this is a stupid question, but I just don't get this module work.
I implemented hook_js() as it is described in the readme:
function my_module_js() {
return array(
'path' => array(
'callback' => 'my_module_somefunction',
'bootstrap' => DRUPAL_BOOTSTRAP_SESSION,
'access callback' => 'user_is_logged_in',
'page arguments' => array(),
'skip_hook_init' => FALSE,
),
);
}
function my_module_somefunction() {
echo 'test';
}
But if I call mysite/js/my_module/somefunction
, I'll get 'Error 404 Page not found'.
I checked whether the module is installed correctly with echo 'test'; exit;
in the js.php file.
That works. Now if I call mysite/js/my_module/somefunction
, I just get 'test' displayed.
So, I read through js.php to check what this file does. I realised, that it checks my_module_js (in the example url above) for the 'somefunction' key. Since there is just the 'path' key, JS_MENU_NOT_FOUND
is returned. If I change 'path' to 'somefunction' and call mysite/js/my_module/somefunction
I get a fatal error:
Call to a member function getDirectoryPath() on a non-object in .../sites/all/modules/print/print_pdf/print_pdf.module on line 70
What do I missing? I guess, that I just forgot a small thing...
I would welcome every advise.
Thanks a lot!
Daniel
Comments
Comment #1
DanielZ123 CreditAttribution: DanielZ123 commentedOk I tried a lot, but I guess I got it now. First I removed
'access callback' => 'user_is_logged_in',
and checked in the callback, whether the user is logged in. Then I added user module, because I has enabled the overlay module (I guess I skipped this sentence in your readme...). But then I got the fatal error:Call to undefined function current_path() in .../modules/overlay/overlay.module
Therefore, I tried to add
'file' => 'includes/path.inc',
tomy_module_js()
, but that did not solve the problem. Since I want the maximum performence anyway, I decided to disable the overlay module, what results in this tinyhook_js()
:This works and reduces the time for my Ajax requests from 420ms to 55ms! Great job guys!
But I would like to know what I did wrong as long as the overlay module is enabled. My
my_module_js()
looks like this then:Thanks!
Comment #2
markhalliwell