module_get_path()
Last updated on
30 April 2025
DEFINITION
function module_get_path($modulename, $filename)
This function should only be used to find files that can exist in either the theme directory or module directory (almost always theme files). These can be any file type like a js file, css file, template file, etc.
$modulename = The name of the module you want to receive a path from
$filename = The filename you want to find. It will check both the current theme directory and if its not found it will check the $modulename directory.
Return Values
String of the path to a file
Examples
//Return the CSS path from the theme dir if it exists, otherwise return the test_module's default css path in the test_module directory
$css_path = module_get_path('test_module', 'test.css');
//This will return either all/sites/themes/$current_theme/test.css OR all/sites/modules/test_module/test.css. The theme and module dont have to be in all/sites btw so that part will change depending on where things were installed and what not.
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion