function module_load_include

Loads a module include file.

Examples:

// Load node.admin.inc from the node module.
module_load_include('inc', 'node', 'node.admin');

// Load content_types.inc from the node module.
module_load_include('inc', 'node', 'content_types');

Do not use this function to load an install file, use module_load_install() instead. Do not use this function in a global context since it requires Drupal to be fully bootstrapped, use require_once DRUPAL_ROOT . '/path/file' instead.

@todo The module_handler service has a loadInclude() method which performs this same task but only for enabled modules. Figure out a way to move this functionality entirely into the module_handler while keeping the ability to load the files of disabled modules.

Parameters

$type: The include file's type (file extension).

$module: The module to which the include file belongs.

$name: (optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default.

Return value

The name of the included file, if successful; FALSE otherwise.

50 calls to module_load_include()
form_get_cache in drupal/core/includes/form.inc
Fetches a form from the cache.
form_load_include in drupal/core/includes/form.inc
Ensures an include file is loaded whenever the form is processed.
forum_overview in drupal/core/modules/forum/forum.admin.inc
Form constructor for the forum overview form.
hook_user_cancel in drupal/core/modules/user/user.api.php
Act on user account cancellations.
ImageEffectsTest::setUp in drupal/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php
Sets up a Drupal site for running functional and integration tests.

... See full list

File

drupal/core/includes/module.inc, line 189
API for loading and interacting with Drupal modules.

Code

function module_load_include($type, $module, $name = NULL) {
  if (!isset($name)) {
    $name = $module;
  }
  if (function_exists('drupal_get_path')) {
    $file = DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "/{$name}.{$type}";
    if (is_file($file)) {
      require_once $file;
      return $file;
    }
  }
  return FALSE;
}