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.

General Questions /

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

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

inserting javascript in template


Go to End


8 Posts   2204 Views

Avatar
anujkryadav

Community Member, 30 Posts

31 December 2009 at 11:42pm

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

Avatar
zenmonkey

Community Member, 545 Posts

1 January 2010 at 5:31am

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 %> 

Avatar
Rishi

Community Member, 97 Posts

20 January 2010 at 2:57am

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

Avatar
zenmonkey

Community Member, 545 Posts

20 January 2010 at 12:53pm

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

Avatar
Rishi

Community Member, 97 Posts

20 January 2010 at 11:52pm

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

Avatar
zenmonkey

Community Member, 545 Posts

21 January 2010 at 3:52am

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

Avatar
Rishi

Community Member, 97 Posts

24 January 2010 at 7:46am

yes it works fine except the flash

Avatar
zenmonkey

Community Member, 545 Posts

24 January 2010 at 9:18am

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