Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Want to add Javascript code to the CMS / Jw Player

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

Page: 1
Go to End
Author Topic: 1547 Views
  • OCO Pure
    Avatar
    Community Member
    14 Posts

    Want to add Javascript code to the CMS / Jw Player Link to this post

    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?

  • OCO Pure
    Avatar
    Community Member
    14 Posts

    Re: Want to add Javascript code to the CMS / Jw Player Link to this post

    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.

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