Jump to:

3431 Posts in 1025 Topics by 864 members

Template Questions

SilverStripe Forums » Template Questions » Variables inside inline Javascript ?

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

Page: 1
Go to End
Author Topic: 1282 Views
  • pinkp
    Avatar
    Community Member
    168 Posts

    Variables inside inline Javascript ? Link to this post

    Is it possible to put Variables inside inline Javascript:

    Where $SlideShowSpeed will become a number from the CMS, currently it outputs nothing...

    MyPage.ss

    ...
    <script type="text/javascript">//<![CDATA[
    ...
       //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
       setInterval('rotate()', {$SlideShowSpeed}000);
       
    }
    ...
    //]]></script>
    ...

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: Variables inside inline Javascript ? Link to this post

    yes this is posible.

    create a method in the controller with the name SlideShowSpeed which returns the value.

  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Variables inside inline Javascript ? Link to this post

    Sorry I wasn't very clear, I have already created the method the problem was it was returning nothing, but after your suggestion I found I was calling the wrong one in the template!! apologies thanks though

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