brianelley Posted January 20, 2010 Share Posted January 20, 2010 Trying this from past 3 days. I really hope someone will help me on this.I want to Homepage Logo Image to slide and show multiple images. To start, I have written a simple code: I have added the following JavaScript in the head section header.tpl to change image every 2.5 seconds:[removed]var image1=new Image();var image2=new Image();var image3=new Image();image1.src="/modules/editorial/homepage_logo1.png";image2.src="/modules/editorial/homepage_logo2.png";image3.src="/modules/editorial/homepage_logo3.png";//variable that will increment through the imagesvar step=1;function slideit(){//if browser does not support the image object, exit.if (!document.images)return;document.images.slide.src=eval("image"+step+".src");if (step<3)step++;elsestep=1;//call function "slideit()" every 2.5 secondssetTimeout("slideit()",2500);};[removed]Modified Body tag line to call the above [removed]<body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}>Added Name tag for Homepage Image in editorial.tpl Link to comment Share on other sites More sharing options...
brianelley Posted January 21, 2010 Author Share Posted January 21, 2010 Message got truncated above. With the above code, a standalone html page is working. But once I put the function in the Head section of JavaScript, the page goes blank. I am certainly new to Preta and would like to know if there is a procedure to add JavaScript functions in tpl files. Any advice would be really appreciated. Thank you!Brian. Link to comment Share on other sites More sharing options...
rocky Posted January 22, 2010 Share Posted January 22, 2010 You need to put {literal} before the script code and {/literal} after. Otherwise, Smarty will read the { in the Javascript code as a Smarty tag, which causes an error. Link to comment Share on other sites More sharing options...
brianelley Posted January 22, 2010 Author Share Posted January 22, 2010 Oh that's great. I have never worked on Smarty as well. Thanks for the help, it is working now. I'll post the URL when the site is ready. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now