Drupal - How to load an include file from Drupal's include folder?

require_once DRUPAL_ROOT . '/includes/actions.inc';

is the correct way.

Using 'content' just worked, because there is no module named content and just did work due to a side-effect. It also caused silent performance problems on Drupal versions < 7.50.

There is no Drupal specific function to load a core include file, and this is how it is done in includes/common.inc line 5242.

  • Fabianx, Drupal 7 core branch maintainer and core committer

With the help of module_load_include() method you can include the core files from the include directory the only thing is you need to pass "content" in the second parameter (i.e: module name).

Working Example on including a file from drupal core includes directory,

module_load_include('inc', 'content', 'includes/actions');

Tags:

7