function module_load_include

Same name in other branches
  1. 9 core/includes/module.inc \module_load_include()
  2. 8.9.x core/includes/module.inc \module_load_include()
  3. 10 core/includes/module.inc \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.

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.

53 calls to module_load_include()
AnnounceFeedTestInvalidJsonTestCase::setUp in modules/announcements_feed/tests/announce_feed_test.test
Sets up a Drupal site for running functional and integration tests.
AnnounceFeedTestRelevantVersion::setUp in modules/announcements_feed/tests/announce_feed_test.test
Sets up unit test environment.
AnnounceFeedTestSanitizationTestCase::setUp in modules/announcements_feed/tests/announce_feed_test.test
Sets up a Drupal site for running functional and integration tests.
AnnounceFeedTestValidateJsonFeed::setUp in modules/announcements_feed/tests/announce_feed_test.test
Sets up a Drupal site for running functional and integration tests.
AnnounceFeedTestValidatePermissions::setUp in modules/announcements_feed/tests/announce_feed_test.test
Sets up a Drupal site for running functional and integration tests.

... See full list

File

includes/module.inc, line 327

Code

function module_load_include($type, $module, $name = NULL) {
    static $files = array();
    if (!isset($name)) {
        $name = $module;
    }
    $key = $type . ':' . $module . ':' . $name;
    if (isset($files[$key])) {
        return $files[$key];
    }
    if (function_exists('drupal_get_path')) {
        $file = DRUPAL_ROOT . '/' . drupal_get_path('module', $module) . "/{$name}.{$type}";
        if (is_file($file)) {
            require_once $file;
            $files[$key] = $file;
            return $file;
        }
        else {
            $files[$key] = FALSE;
        }
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.