Jump to:

1368 Posts in 487 Topics by 520 members

Themes

SilverStripe Forums » Themes » JavaScript adding to themplete

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 757 Views
  • silus
    Avatar
    Community Member
    2 Posts

    JavaScript adding to themplete Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: JavaScript adding to themplete Link to this post

    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"
    ));

    757 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.