Drupal で、モジュールやテーマのあるディレクトリ名(パス名)を取得する方法(drupal_get_path)

こんな感じ。'module' とあるところは 'theme' にするとテーマのあるディレクトリ名を調べることができる。より一般化すると drupal_get_path($type, $name) という関数なのだが、$type には 'module'、'theme'、'theme_engine' などが入る。英語での複数の「s」は、この関数の中でこっそり付与されているので必要ない。この $type は、system テーブルの type フィールドにあるもの。 <?php $module_dir = drupal_get_path('module', 'your_module_name'); ?> <?php $theme_dir = drupal_get_path('theme', 'your_theme_name'); ?>