Home ›
Include a file nested within a module directory wit Drupal 7's module_load_includeInclude a file nested within a module directory wit Drupal 7's module_load_include
Submitted by Benjamin Melançon on May 5, 2012 - 4:57am
The documentation for module_load_include doesn't mention it, but if a file is in a subdirectory in its module folder, or even nested several levels deeper, this module-relative path should be included with the file name in the third parameter.
<?php
module_load_include('inc', 'page_manager', 'plugins/tasks/node_view');
?>Note that this is module-relative, not project-relative. For instance, in the example above page_manager is in the ctools project.
More like this
- Stumbling through DBTNG, Drupal 7's new database layer
- Adding non-menu things to primary links menu items with Drupal 7's page alter hook
- Loading included files the Drupal way
- Drupal 7's jobqueue doesn't guarantee your hard drive won't be hit by a meteor
- Usernode module causes nesting level too deep (recursion) in Devel's Macro module


Comments
Post new comment