Hello,

I've got some additional Javascript I'd like to run on my site. Right now I've put it inside my custom theme directory, i.e:

sites/all/themes/mytheme/scripts/myscript.js

and in my theme template.php I call:

drupal_add_js(drupal_get_path('theme','deco') . "/scripts/myscript.js");

This all works fine, but I'd like to put the scripts somewhere where I can use them for multiple themes. Is there some "drupal wide" way of adding scripts, that doesn't depend on the theme?

If not, then I suppose I could put the scripts in theme root, i.e: sites/all/themes/scripts and call:

drupal_add_js(drupal_get_path('theme','deco') . "../scripts/myscript.js");

within each of my theme's template.php. ... it just doesn't *feel* right :)

Comments

Anonymous’s picture

put the js files in a theme subdir.
Why not sites/all/scripts ?

-----------------------------------------
Joep
CompuBase, Drupal websites and design

ardarvin’s picture

I suppose so. So then for each theme I'd have to edit the template.php to say:

drupal_add_js(drupal_get_path('theme','mytheme') . "../../scripts/myscript.js");

?? I suppose that is my real question... how to get the scripts "inside" of drupal. The only way I know how to at the moment is using "drupal_add_js" inside the theme, as described above.

Anonymous’s picture

Again: Why not in the directory sites/all/scripts ?
You can include the js file in your page.tpl.php rather then calling drupal_add_js.

-----------------------------------------
Joep
CompuBase, Drupal websites and design

ardarvin’s picture

Thanks, that seems to work best.