5

I am experiencing a problem with the GlobalRedirect module in that it seems like it is not loading the locale.inc which it relies upon. I tried using the module_load_include function but did not work as locale.inc isn't apart of a module.

I know I can use:

include(DRUPAL_ROOT."/includes/locale.inc");

Is there a Drupal specific function call to load include files for Drupal? I am curious if there is.

Thanks

3

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');
  • 1
    Never realized I could include these files using module_load_include – AyeshK Nov 28 '13 at 19:03
  • It was the 'content' keyword that I was missing. Thanks. – user5013 Nov 28 '13 at 19:14
  • it seems to me the OPs original method is fine (and shorter) - what am I missing? – ErichBSchulz Feb 2 '14 at 11:04
  • 2
    This approach causes the warnings "The following module is missing from the file system: content", and is not the correct approach. See @LionsAd's solution instead for the right way. – jdhildeb Aug 23 '17 at 17:50
8
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
  • 1
    > 7.50 you'll end up with "The following module is missing from the file system: content" errors – kreynen Aug 30 '16 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.