digitalecartoons — 2012-08-11T06:26:07-04:00 — #1
In my Drupal site I want to include the swfobject.js script to my pages so added the location in the template.info file:
scripts = sites/all/libraries/swfobject/swfobject.js
When I view my pages however, it is added to I guess a default script location, being the following
So when I view the source code of my site the complete line becomes:
How can I point it to the correct location:
I've tried using something like:
scripts = ..sites/all/libraries/swfobject/swfobject.js
but those first two dots just get added to that default line:
awasson — 2012-08-11T13:37:05-04:00 — #2
scripts = /sites/all/libraries/swfobject/swfobject.js
digitalecartoons — 2012-08-12T06:14:09-04:00 — #3
No, that didn't work. It became:
It's like everything you place behind scripts is just added to the default theme location. In this case it now has two slashes behind www.mysite/sites/all/themes/mytheme.
There doesn't seem to be a way to have it move up the directory tree when I use scripts?
I now did it by placing a libraries folder inside my theme folder (where the other files/images etc. also are) and direct it simply to that directory. with scripts libraries/swfobject/swfobject.js.
awasson — 2012-08-12T12:21:58-04:00 — #4
Oh, I see what you mean... The script line isn't parsed as a path, it's a piece of text that is attached to the site root + path to theme and printed to the html template. I didn't expect that.
It's not as clean as adding it to the info file but you could add your file directly to html.tpl.php (D7) or add it using a block with the drupal_add_js(); function.
oddz — 2012-08-12T14:10:58-04:00 — #5
The best method to add third party code like that would be to register it as a library implementing [hook_library. Than use the function [url=http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_library/7]drupal_add_library()](http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_library/7) to actually add the library to the request output.
mittineague — 2014-09-21T18:40:53-04:00 — #6
This topic is now archived. It is frozen and cannot be changed in any way.