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

177 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

1 string reference to 'drupal_get_path'
module_load_include in includes/module.inc
Loads a module include file.


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


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


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

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

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.

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


(drupal_get_path('library', 'modernizr') . '/js/modernizr-1.6.min.js',
'group' => JS_THEME, 'every_page' => TRUE));

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

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

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

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.

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

('syntaxhighlighter_3.0.83', TRUE);

Does it possible to override this function ?

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

No. That location is stored as a variable.

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