8.5.x bootstrap.inc drupal_get_path($type, $name)
8.0.x bootstrap.inc drupal_get_path($type, $name)
8.1.x bootstrap.inc drupal_get_path($type, $name)
8.2.x bootstrap.inc drupal_get_path($type, $name)
8.3.x bootstrap.inc drupal_get_path($type, $name)
8.4.x bootstrap.inc drupal_get_path($type, $name)
8.6.x bootstrap.inc drupal_get_path($type, $name)
4.6.x common.inc drupal_get_path($type, $name)
4.7.x common.inc drupal_get_path($type, $name)
5.x common.inc drupal_get_path($type, $name)
6.x common.inc drupal_get_path($type, $name)
7.x common.inc drupal_get_path($type, $name)

Returns the path to a system item (module, theme, etc.).


$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.

163 calls to drupal_get_path()
AggregatorTestCase::getAtomSample in modules/aggregator/aggregator.test
AggregatorTestCase::getHtmlEntitiesSample 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.

... See full list


includes/common.inc, line 2890
Common functions that many Drupal modules will need to reference.


function drupal_get_path($type, $name) {
  return dirname(drupal_get_filename($type, $name));


mlncn’s picture

  • It returns the path without slashes in front or after.
  • That's the type *first*, then the project name
    drupal_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...

  • The valid types are as listed:
    • module
    • theme
    • profile
    • theme_engine

    I can't think of any others and i can't even think of a reason to use the last one.

jlporter’s picture

link to all valid types or at least listing them would be nice.

micheas’s picture

The 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.

jromero1214’s picture

Is there any way to properly get the path to a library?


drupal_add_js(drupal_get_path('library', 'modernizr') . '/js/modernizr-1.6.min.js',
							array('group' => JS_THEME, 'every_page' => TRUE));
techkey’s picture

Yes, there is a way. The function is in the libraries module.

drupal_add_js(libraries_get_path('modernizr') . '/js/modernizr-1.6.min.js', array('group' => JS_THEME, 'every_page' => TRUE));
blw0010’s picture

What does this parameter of the drupal_add_js function do?
array('group' => JS_THEME, 'every_page' => TRUE)

BAM5’s picture

Documentation is located here.

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.

sheldonkreger’s picture

It took me some time to figure out the machine name required for $name variable in libraries_get_path($name). The library name, in my case, matches the name of the folder that you unpack inside sites/all/libraries. For example libraries_get_path('syntaxhighlighter_3.0.83', TRUE);

_redfog’s picture

Does it possible to override this function ?

tinflute’s picture

I want to move files in and out of sites/default/files
Is that location accessible with this function?

agentrickard’s picture

No. That location is stored as a variable.

$files_dir = variable_get('file_public_path', conf_path() . '/files')