Drupal 7 .install 文件

Drupal 7 .install files

有没有办法让 MODULE.install 在其他文件中使用代码,大概类似于 MODULE.info 中的 files[] = 命令?我假设我可以使用 require 语句,但这似乎是一种反 Drupal 的做事方式。

Clive 的评论对我有用。

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

我在函数中使用了 module_load_include();我没有尝试 require_once()。基于 module_load_include() 代码,以下应该有效:

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