| 7 common.inc | drupal_get_path($type, $name) |
| 4.6 common.inc | drupal_get_path($type, $name) |
| 4.7 common.inc | drupal_get_path($type, $name) |
| 5 common.inc | drupal_get_path($type, $name) |
| 6 common.inc | drupal_get_path($type, $name) |
| 8 common.inc | drupal_get_path($type, $name) |
Returns the path to a system item (module, theme, etc.).
Parameters
$type: The type of the item (i.e. theme, theme_engine, module, profile).
$name: The name of the item for which the path is requested.
Return value
The path to the requested item or an empty string if the item is not found.
172 calls to drupal_get_path()
- AggregatorTestCase::getAtomSample in modules/
aggregator/ aggregator.test - AggregatorTestCase::getRSS091Sample in modules/
aggregator/ aggregator.test - AggregatorUpdatePathTestCase::setUp in modules/
simpletest/ tests/ upgrade/ update.aggregator.test - Overrides DrupalWebTestCase::setUp() for upgrade testing.
- aggregator_test_feed in modules/
aggregator/ tests/ aggregator_test.module - Page callback. Generates a test feed and simulates last-modified and etags.
- AJAXFrameworkTestCase::testLazyLoad in modules/
simpletest/ tests/ ajax.test - Test that new JavaScript and CSS files added during an AJAX request are returned.
1 string reference to 'drupal_get_path'
- module_load_include in includes/
module.inc - Loads a module include file.
File
- includes/
common.inc, line 2803 - Common functions that many Drupal modules will need to reference.
Code
function drupal_get_path($type, $name) {
return dirname(drupal_get_filename($type, $name));
}
Comments
More information
Permalinkdrupal_get_path('module', 'name_of_module');I reverse that enough (and then get confused as to why it isn't working) that i felt it worth documenting here, so the 'doh!' moment of realization comes sooner...
I can't think of any others and i can't even think of a reason to use the last one.
link to types
Permalinklink to all valid types or at least listing them would be nice.
Some common types
PermalinkThe common types that I have used are module, theme, library and base.
I am sure that it is possible to have other ones, as it is at least theoretically extensible.
Libraries?
PermalinkIs there any way to properly get the path to a library?
Example:
<?phpdrupal_add_js(drupal_get_path('library', 'modernizr') . '/js/modernizr-1.6.min.js',
array('group' => JS_THEME, 'every_page' => TRUE));
?>
libraries module
PermalinkYes, there is a way. The function is in the libraries module.
Example:
<?phpdrupal_add_js(libraries_get_path('modernizr') . '/js/modernizr-1.6.min.js', array('group' => JS_THEME, 'every_page' => TRUE));
?>
Can you explain?
PermalinkWhat does this parameter of the drupal_add_js function do?
array('group' => JS_THEME, 'every_page' => TRUE)
Simple
PermalinkDocumentation is located here.
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad...
Basically, the group is a weight level, with the javascript entries having their own weight below that particular group, and every_page denotes whether or not the js should be added to every page.
Override drupal_get_path
PermalinkDoes it possible to override this function ?
How to return public files folder?
PermalinkI want to move files in and out of sites/default/files
Is that location accessible with this function?
No. That location is stored
PermalinkNo. That location is stored as a variable.
<?php$files_dir = variable_get('file_public_path', conf_path() . '/files')
?>