Add Javascript to a theme

Go down

Add Javascript to a theme

Post  martin2020 on Sun Apr 17, 2011 8:31 am


I try to add javascript to a theme. I found out that the path 'images' can be found if put in a theme, and 'img' not.
Now, if I would like to add some Javascript from a folder 'js' in the themes-dir, how would I add this??

Seo Marketing|Link Building


Posts : 259
Join date : 2011-03-08

View user profile

Back to top Go down

Re: Add Javascript to a theme

Post  JamesRobert on Mon Jul 18, 2011 12:57 am

The PHP function drupal_add_js() lets you add a JavaScript file, setting or inline code to the page and it takes 5 parameters (see the api reference).

The first parameter is always going to be a path to a js file, an array, or a piece of JavaScript code. If the second parameter is 'module' (the default), 'theme', or 'core', then the first parameter must be a path and the only difference between these three is the order in which the script tag will be placed relative to other scripts, i.e. core scripts first, then module scripts and finally theme scripts.


Posts : 1
Join date : 2011-07-18

View user profile

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum