I really appreciated the README in the js subfolder, which has this info:

2. To add a JavaScript file depending on a certain condition, you can add it
   using some PHP code in a preprocess function:

     drupal_add_js(drupal_get_path('theme', 'THEME_NAME') . '/js/my-jquery-script.js', array('group' => JS_THEME));

Even though I've done this sort of thing before, it saved me having to go look it up. I'm sure it's even more useful to theming newbies! It's a very nice touch -- thanks! :)

However, in template.php, it's easier to say path_to_theme() rather than drupal_get_path('theme', 'THEME_NAME') -- unless there are some ramifications of path_to_theme() that I'm not aware of.


JohnAlbin’s picture

Issue summary: View changes
Status: Active » Fixed

path_to_theme() returns the path to the current template file. And (drupal_get_path('theme', 'THEME_NAME') returns the path to the root directory of the named theme.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.