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.

Template Questions /

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

Variables inside inline Javascript ?


Go to End


3 Posts   2049 Views

Avatar
pinkp

Community Member, 182 Posts

9 June 2010 at 12:08am

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

Avatar
bartvanirsel

Community Member, 96 Posts

9 June 2010 at 7:44am

yes this is posible.

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

Avatar
pinkp

Community Member, 182 Posts

9 June 2010 at 7:50am

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