I have enough functions in this module that I want to split them into different files to keep them organized. I have:

my_module.info
my_module.module
my_module_more_functions.module

In my .info file I have the line:
files[] = my_module_more_functions.module

I call a function in the more_functions file and I get the error. Drupal is not seeing the functions in the second file.
Before you ask...I am clearing the cache.

How do I split functions into different files So I don't get one gigantic .module file?

Comments

Anonymous’s picture

I would use '.inc' as your file extension rather than '.module' as that might cause Drupal to behave a bit funny. You're doing it the right way though, using the files array in the .info file

keithm’s picture

Check out module_load_include(): http://api.drupal.org/api/drupal/includes--module.inc/function/module_lo.... Also, you would generally load your different functions as needed, not unconditionally.

esnyder’s picture

OK. That did the trick. I did change the name of the file extension but that did not help.

tomrenner’s picture

Thanks, Keith! This has helped me a lot, too! Funny thing is, that I could not find this trick described anywhere else on the API. I have simply included the line in my .module file at the very top (no idea if this is best practice ;-) but it simply works!