By amino_ab on
Hello,
I have a serious problem :)
I am creating a new module mymodule.module. I have one function that seems to be a hook but it's not a real one. I have called
it :
function mymodule_myfunction() {
return "Thanks Drupal!";
}
I have added mymodule. Now I have created a new "PHP code" node. I would like to invoke this function from the node so I want to write something like below in the body of the node :
print module_invoke ('mymodule', 'myfunction');
But it doesn't work :((
I Check with function_exists('myfunction'), it's not found!
How to explain this? and how to call this function?
Regards.
Comments
Mind the names
Your function_exists('myfunction') doesnt work, because your functions
is named 'mymodule_myfunction' and not 'myfunction' only.
I think you got the same problem with your hook: module_invoke takes
the modules name (without .module) as first parameter and the function
to invoke as second parameter. So you should try:
module_invoke ('mymodule', 'mymodule_myfunction');
correction
and to invoke this function :
but to check the existence of the function you are right :
Anyway, it is still not working!
This still isn't right
To invoke the function, you wrote:
It should be:
from module.inc
module_hook is returning false in my case.
why?
Have you enabled your module?
Have you enabled the module under admnister -> modules?
Of course enabled!
Yes, it's enabled and I can see all the standard hooks (_view, _form, ..) but function_exists fails with customized functions. I have trying to solve the problem by adding one include.inc file. It works of course, but I still want the clean solution.
:)
Uuupps. Sorry! You are right with module_invoke, of course!
When function_exists returns true with your arguments, how can
module_hook return false then?