You can add all your javascript files to the js
folder in your theme like:
sample-theme/docroot/_diffs/js/jquery-1.8.2.min.js
And then to make it available for everybody you can write any of the following lines in the <head>
section of the template files portal_normal.vm
and portal_pop_up.vm
present in the directory sample-theme/docroot/_diffs/templates/
:
#js ("$javascript_folder/jquery-1.8.2.min.js")
Or
<script src="$javascript_folder/jquery-1.8.2.min.js"></script>
Note: portal_pop_up.vm
is for applying your javascript changes to AUI dialog pop-ups, if you are using them
Some more explanation as to how things work:
$javascript_folder
is a velocity variable present in the theme's template files which points to the javascript storage path (default is: ${root-path}/js
) which can be defined in the liferay-look-and-feel.xml
like this:
<theme id="sample" name="Sample">
<root-path>/html</root-path> <!-- optional -->
<javascript-path>${root-path}/js/jQuery</javascript-path> <!-- So path becomes: sample-theme/html/js/jQuery -->
</theme>
You can also customize ${root-path}
just like <javascript-path>
by specifying it in liferay-look-and-feel.xml
as <root-path>
as shown. The default value of ${root-path}
is /
i.e. it refers to the directory sample-theme/
.
Basically the folders css
, js
, templates
& images
are the ones which gets updated with the changes you make in the corresponding _diffs
folder (_diffs/css
, _diffs/js
etc) when you build the theme. So that is the reason the velocity variables like $javascript_folder
& $css_folder
point to sample-theme/js
& sample-theme/css
respectively instead of sample-theme/_diffs/js
or sample-theme/_diffs/css
.
Hope this helps.