Jump to:

23369 Posts in 18155 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » inserting javascript in template

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1400 Views
  • anujkryadav
    Avatar
    Community Member
    30 Posts

    inserting javascript in template Link to this post

    hello
    I am trying to insert a 3d gallery in my homepage,thought the gallery is running fine in a normal html page,i want to insert the same gallery in silverstripe.
    My gallery consist of a js file(javascript file) one XML file which have information about the picture i am using and a html code to call the files.all the files are under a folder under the root.
    when i insert the below code the gallery is showing correctly in a html file

    <script type="text/javascript">
          var fo = new SWFObject("TiltViewer.swf", "viewer", "100%", "100%", "9.0.28", "#000000");         
          // XML GALLERY OPTIONS
          // To use local images defined in an XML document, use this block      
          fo.addVariable("useFlickr", "false");
          fo.addVariable("xmlURL", "gallery.xml");
          fo.addVariable("maxJPGSize","640");
          
          //GENERAL OPTIONS      
          fo.addVariable("useReloadButton", "false");
          fo.addVariable("columns", "3");
          fo.addVariable("rows", "3");
          
          
          // END TILTVIEWER CONFIGURATION OPTIONS
          
          fo.addParam("allowFullScreen","true");
          fo.write("flashcontent");         
        </script>   

    Please help me in inserting this code in homepage

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: inserting javascript in template Link to this post

    Well the easiest way is to just wrap the Javascript in an if control in your Page.ss

    <% if Title == "Home" %>
    insert your code here
    <% end_if %>

  • Rishi
    Avatar
    Community Member
    97 Posts

    Re: inserting javascript in template Link to this post

    Hello I tried the suggested way but its not working any alternative

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: inserting javascript in template Link to this post

    How is it not working? Is the Javascript not being rendered or the javascript not working?

  • Rishi
    Avatar
    Community Member
    97 Posts

    Re: inserting javascript in template Link to this post

    when I have added the code as per your instruction nothing is displayed on the page do i need to give the path of xml and swf file ,how to do that

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: inserting javascript in template Link to this post

    Nothing is rendering at All? You get a totally blank page. Did the page work before?

  • Rishi
    Avatar
    Community Member
    97 Posts

    Re: inserting javascript in template Link to this post

    yes it works fine except the flash

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: inserting javascript in template Link to this post

    If its only the flash thats not working you probably it probably can't find your XML file or the call to the flash file is wrong. You shoudl be able to embed a flash file liek you would in a static page and then configure it per the Flash Viewers instructions to find the XML

    1400 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.