Search code examples
drupal-7drupal-modules

Drupal 7 .install files


Is there a way I can get a MODULE.install to use code in other files, presumably something analogous to the files[] = command in MODULE.info? I assume that I can use a require statement, but this seems to be an anti-Drupal way of doing things.


Solution

  • Clive's comment worked for me as an answer.

    Use module_load_include() inside functions, require_once if you're including in the global scope – Clive

    I used module_load_include() in a function; I did not try require_once(). Based on the module_load_include() code, the following should work:

    require DRUPAL_ROOT . '/' . drupal_get_path('module', $my_module_name) . "/$my_file_name";