I am trying to make it work, but it seems simply not working in Drupal 6. Maybe this is the issue, it does not work on D6?

This is the code:

// $file_path = module_load_include('inc', 'MYMODULE.inc', 'includes/MYMODULE.inc');
$file_path = module_load_include('MYMODULE', 'MYMODULE.inc');

// Testing.
if ($file_path === FALSE) {
  dpm('Failed to include: ' . $filename);
else {
  dpm('Successfully included: ' . $file_path);

I have tried also adding a drupal_load before and some other things, like changing params, moving the inc file to the root module folder and so, but I allways get the same:

Failed to include: sites/all/modules/MYCOMPANY/MYMODULE/MYMODULE.module

any idea of what am I doing wrong?

Thanks a log.


You need to add inc into your implementation of the function. Also you don't need to add the extension .inc as part of the filename:

$file_path = module_load_include('inc', 'MYMODULE', 'FILENAME');

Documentation: module_load_include();.


The arguments expected from module_load_include() are, in order, the following:

  • The extension of the file to load
  • The name of the module whose directory is looked for the file
  • The name of the file (without extension)

In your case, the call to module_load_include() should be:

  • module_load_include('inc', 'MYMODULE', 'includes/MYMODULE'), in the first case
  • module_load_include('inc', 'MYMODULE') in the second case

In the first case, the loaded file is includes/MYMODULE.inc, contained in the "includes" directory contained in the directory containing MYMODULE.module; in the second case, the file is MYMODULE.inc contained in the same directory containing MYMODULE.module.

When the third argument is not passed, the name of the file is the name of the module without .module extension.

Your Answer

