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.

Themes /

Discuss SilverStripe Themes.

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

Creating a theme with javascript....


Go to End


3 Posts   4757 Views

Avatar
Kaitar

Community Member, 3 Posts

17 April 2009 at 8:46am

Hello!

I am new to SilverStripe, and I am attempting to build my first theme, however I am trying to include a few javascript functions, but I can't seem to get them working at all.

I have figured out how to use the Require:: tag so that the javascript files that I'm wanting to use get loaded into the page, but it doesn't seem that the javascript actually works.

The first one that I'll talk about is Cufon.js, which is a script that will dynamically go through and replace text with images using a non-standard font face. If you want to read more about cufon, please go here: http://wiki.github.com/sorccu/cufon

On a standard site, you load the javascript files for cufon (cufon.js and the font.js) and insert a replace command for the CSS id that you want replaced. Example:

<script src="content/cufon.js" type="text/javascript"></script>
<script src="content/SNC_Script_italic_400.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('#direction');
</script>

I have this exact same thing on my SilverStripe site, but it is not replacing the content of the div id "direction", even though it should be.

Avatar
Willr

Forum Moderator, 5523 Posts

18 April 2009 at 6:56pm

Couple things to check

- Are all the JS files loaded
- Are there any JS errors preventing it loading?
- Does the outputted HTML validate? If it is strict and it does not validate then some JS is may not be applied to the page.
- Is the path to the font.js file correct?

Avatar
Kaitar

Community Member, 3 Posts

19 April 2009 at 4:46pm

Will,

Thanks for the reply - you have it - my HTML wasn't able to validate, and as soon as I fixed that problem I had my other one fixed.

Thank you again!