I am porting an Drupal 6 package and it's modules to Drupal 7, and as part of that I want to extract some common functions in those modules to a single file . Where can I find the preferred method for this? or examples of another package with modules sharing common functions? Thanks

Comments

Jaypan’s picture

Any functions placed in any .module file are open to any other module. API modules expose their functions by putting them into the .module file.

If you want to keep them all separate, you can put them all in a separate .inc file, and either include that in every page load, or require that any modules that want to use the API include this file first.

sunnydeveloper’s picture

Thank you - I currently have the functions in a .module, but since they are generic to a group of modules, I prefer to separate them out. thanks for your response