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.

Customising the CMS

Want to add Javascript code to the CMS / Jw Player


Reply

2 Posts   1647 Views

Avatar
OCO Pure

19 April 2010 at 8:20am Community Member, 14 Posts

The task is not new, adding JW Player to Silverstripe. The DataObjectManager from UncleCheese is doing a great job so far, but I would like to have it a little more flexible. I have come across this http://doc.silverstripe.org/doku.php?id=recipes:customising-content-in-your-templates and thought it might be well working for me.
So I added

      function Content() {
       return str_replace('$video', $this->silverVideo(), $this->Content);
   }
      // see the $this->PaypalButton() string up 2 lines? well that calls the Paypal() method below
      function silverVideo() {
       return $this->renderWith('video');

   }

to the Page_Controller class and the tried different ways with including the JW Player embedding code.

Trying for a while now, I have come to the point where I simply not understand why Silverstripe is behaving like this. I have used the <object> and <embed> tag to include the JW Player to the site, simply using a $video token. I have also tried with using php to start the player, with no result at all. Using the code on a non-SS site, it`s fully working and behaving like it should be.

Does anyone got an idea, how to have this code

<script type='text/javascript' src='http://www.mysite/player/swfobject.js'></script>

<div id='mediaspace'>This text will be replaced</div>

<script type='text/javascript'>
var so = new SWFObject('http://www.mysite/player/player.swf','mpl','420','315','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('author','');
so.addVariable('description','');
so.addVariable('file','http://www.mysite/player/twister2009.flv');
so.addVariable('controlbar','none');
so.addVariable('autostart','true');
so.write('mediaspace');
</script>

run by SS without kicking all the TinyMCE rules and hacking the back of the system?

When reading the forums, this is a problem not only I have. So it might be of public interest to have this solved.

Ideas anyone?

Avatar
OCO Pure

21 April 2010 at 8:07am Community Member, 14 Posts

Thanx to my buddy Stefan, he found the problem preventing the Javascript from being executed.

There seems to be a bug/feature within the system that is blocking templates with numbers in the .ss name. The secret was to change the name of the .ss file in the themes/yourtheme/templates/Includes directory to a name with only letters in it.