Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Themes /

Discuss SilverStripe Themes.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

JavaScript adding to themplete


Go to End


2 Posts   1731 Views

Avatar
silus

Community Member, 2 Posts

7 January 2012 at 3:23am

hi!

so, i have this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/jquery.easing.compatibility.js"></script>
<script type="text/javascript" src="js/coda-slider.1.1.1.js"></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/start.js"></script>
<script type="text/javascript">Cufon.now();</script>

and i need to add it to Page.ss
should it look like this:
<% static void javascript(http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js) %>
(...)
<% static void javascript(Cufon.now();) %>

thanks for the reply, coz i cant understand from the manual how to do this.

:)

Avatar
Willr

Forum Moderator, 5523 Posts

7 January 2012 at 9:03pm

See http://doc.silverstripe.org/sapphire/en/reference/requirements#including-inside-template-files.

For the final line you can just keep it as a script tag.

If you're including all those files, perhaps you want to minify and combine the files. This time in your PHP Page.php init function (has to be via the Requirements PHP API as the template one doesn't support the syntax in 2.*)

Requirements::combine_files("main.js", array(
"js/jquery.easing.1.3.js",
"js/jquery.easing.compatibility.js",
"js/coda-slider.1.1.1.js",
"js/cufon-yui.js",
"js/start.js"
));