0

I'm building a custom module that uses functions from other modules. Specifically the node_clone module. I'm building a custom module to clone a certain content type from a selected user to another selected user.

In my custom module I'm adding those lines:

module_load_include('inc', 'node_clone', 'clone.pages');
clone_node_save($nid);

The function clone_node_save is defined in the module "node_clone", in the root folder of that module,

function clone_node_save($nid, $account = NULL) {
//Function Content
}

inside a file called clone.pages.inc

yet those 2 lines of code give me the error Fatal error: Call to undefined function clone_node_save()

I also tried making a function inside node_clone.module that calls clone_node_save but that gets the same error.

This is drupal 7

  • I just realized module_load_include is returning false – user3713929 Jun 8 '17 at 23:40
  • It is enabled. I can call functions from clone_node.module. And I can use the module in the backend. But I cannot call functions from clone.pages.inc (which is an include in that module) – user3713929 Jun 8 '17 at 23:49
1

You don't include the file extension in the third argument.

So this:

module_load_include('inc', 'node_clone', 'clone.pages.inc');

Should be this:

module_load_include('inc', 'node_clone', 'clone.pages');
|improve this answer|||||
  • My bad, I tried that earlier and it gives the same result. And drupal_get_path('module', 'node_clone'); returns empty – user3713929 Jun 8 '17 at 23:46
  • Sounds like the node clone module is not enabled. – Jaypan Jun 8 '17 at 23:49
  • It is enabled. I can call functions from clone_node.module. And I can use the module in the backend. But I cannot call functions from clone.pages.inc (which is an include in that module) – user3713929 Jun 8 '17 at 23:50
  • Is there any way I can provide the full path to include this module? Its located in /sites/all/modules/contrib/node_clone – user3713929 Jun 8 '17 at 23:56
0

I was using the wrong name for the module. The .info file says project = "node_clone", which I assumed was the machine name of the module (its also the name of the folder). But the actual module is called clone.module, And I noticed this name in the System table when I was checking the path for the clone module.

Cheers!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.