Jump to:

23360 Posts in 18097 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Embed problem!

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2 3
Go to End
Author Topic: 3539 Views
  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Embed problem! Link to this post

    I am trying to add the Unity3D (www.unity3d.com) web player into my site with SS 2.4.5. What seems to happen is that SS is dynamically removing my code that contains the web player. It leaves a closing div tag.

    it is really simple for a simple static page to embed the web player. You need the following code and it works perfectly.
    HTML:

    <script type="text/javascript" src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js"></script>
          <script type="text/javascript">
          <!--
    //gets the unityPlayer div and replaces the content with an embed tag which is the web player made by Unity (it works outside of SS.)
          function GetUnity() {
             if (typeof unityObject != "undefined") {
                return unityObject.getObjectById("unityPlayer");
             }
             return null;
          }
    //sets the parameters of the web player
          if (typeof unityObject != "undefined") {
             unityObject.embedUnity("unityPlayer", "MazePuzzle.unity3d", 720, 450);
             
          }
          -->
          </script>

    <div id="unityPlayer">
                <div class="missing">
                   <a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
                      <img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
                   </a>
                </div>
             </div>

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Embed problem! Link to this post

    From where are you trying to add this code? From within the TinyMCE editor, or from somewhere in your SilverStripe templates/code

  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    From directly within the *.ss page

    Thing is that the code you see within the <div id="unityPlayer"> is automatically replaced by an <embed ...> tag which contains the game
    It swaps the link to download the plugin to the embedding of the plugin if it is installed, otherwise you see the download link.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Embed problem! Link to this post

    Placing a <script> tag directly into your template doen't always work as you'd expect it to. The 'SilverStripe way' would be using the Requirements class to add custom javascript. I ususally do this from within my init() function. Have a look at this link

    http://doc.silverstripe.org/sapphire/en/reference/requirements#custom-inline-scripts

  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    I did that, the code works, and is actually already integrated with the SS Requirements tag.
    I did not place a <script> tag for it.

    The issue is that when the <embed> tag is to be added dynamically to the page code, for some reason silverstripe prevents it from happening.
    I know this is the issue, but i dont know what to change in SS to stop it from happening.

    I know the javascript code executes since it does remove the content already inside the <div> for the case when the plugin is not found.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Embed problem! Link to this post

    OK, took some time for me to really get this What you're saying is something is interfering with the execution of your JavaScript. Looks like it starts replacing the content of your div as it should, and then fails.

    Did you try Firebug to track for JavaScript errors? does your page source contain more JavaScript that might be conflicting?

  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    Hey,

    thanks for the suggestion.
    It seems that i have problems with the css, but the weird thing is i did not even touch that part of the code...

    <head>
          <% base_tag %>
          $MetaTags
          <link rel="stylesheet" type="text/css" href="tutorial/css/layout.css" />
          <link rel="stylesheet" type="text/css" href="tutorial/css/typography.css" />
          <link rel="stylesheet" type="text/css" href="tutorial/css/form.css" />
       </head>

    thats what's in the page.ss file by default. (I get 404: not found messages for all 3 css files)
    i tried changing it to:

    <head>
          <% base_tag %>
          $MetaTags
          <link rel="stylesheet" type="text/css" href="theme/tutorial/css/layout.css" />
          <link rel="stylesheet" type="text/css" href="theme/tutorial/css/typography.css" />
          <link rel="stylesheet" type="text/css" href="theme/tutorial/css/form.css" />
       </head>

    to fix the location of the files, but i still get "404-not found" for the css files.
    (My plugin for the game depends on some css tags as well, so this might just be the issue)

    the thing that i dont understand is that the CSS still seems to properly apply to the webpage, well the theme seems to apply...

  • LostBalloon
    Avatar
    Community Member
    16 Posts

    Re: Embed problem! Link to this post

    nevermind my last post. Fixed that stupid issue, figured the css code was redundant as they had put it in the page.php as well...

    And i use google chrome, and in the dev tools, i dont get any error messages coming from the javascript nor from the page structure.

    3539 Views
Page: 1 2 3
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.