7

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

2 Answers 2

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');
4
  • 1
    Never realized I could include these files using module_load_include
    – AKS
    Commented Nov 28, 2013 at 19:03
  • It was the 'content' keyword that I was missing. Thanks.
    – user5013
    Commented Nov 28, 2013 at 19:14
  • it seems to me the OPs original method is fine (and shorter) - what am I missing? Commented Feb 2, 2014 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
    Commented Aug 23, 2017 at 17:50
9
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
  • 1
    > 7.50 you'll end up with "The following module is missing from the file system: content" errors
    – kreynen
    Commented Aug 30, 2016 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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