CMS & WordPress
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:
scripts = /sites/all/libraries/swfobject/swfobject.js
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.
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.
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.
This topic is now archived. It is frozen and cannot be changed in any way.