Jump to:

22998 Posts in 11620 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Embed an iframe into a page

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
Go to End
Author Topic: 5429 Views
  • freefor
    Avatar
    Community Member
    1 Post

    Embed an iframe into a page Link to this post

    Hi o/ I have a problem embeding iframes into a page I'm using SS 2.3.0 and I can't embed iframe like google maps.I searched on the forum but it didn't help. I tried this method:To enable it, add iframe[src|width|height] to extended_valid_elements in /cms/javascript/tinymce.template.js. After adding it would look like this extended_valid_elements : "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],iframe[src|width|height]" - but when I opened that file there wasn't that string. Help

  • wdi2
    Avatar
    Community Member
    10 Posts

    Re: Embed an iframe into a page Link to this post

    In SS 2.3.0 the code you want to change is commented out in /cms/javascript/tinymce.template.js

    look in jsparty\tiny_mce2\tiny_mce_src.js

    search for 'valid_elements :' should around line 6760

    add iframe[src|width|height] here and that should do the trick for you

  • ste
    Avatar
    Community Member
    8 Posts

    Re: Embed an iframe into a page Link to this post

    Hi,

    I want to try to do the same , embed an inframe, but hacking jsparty/tiny_mce2/tiny_mce_src.js by adding iframe[src|width|height] in the valid elements list doesn't work for me.

    I am running ss 2.3.0.

    Do you have to do anything after add ?

    Ste

  • wdi2
    Avatar
    Community Member
    10 Posts

    Re: Embed an iframe into a page Link to this post

    Hi,

    Below is the code I added, but adding iframe[src|width|height] also worked for me.

    ... img[longdesc|usemap|src|border|alt=|title|hspace|vspace|width|height|align],iframe [align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight| marginwidth|name|scrolling<auto?no?yes|src|style|title|width],-sub, ...


             
    The contents of the iframe don’t load in the content editor (though you can set a border in editor.css to see where it is located), but do in the live site. The above just ensures the html is not striped out completely.

    I am using 2.3.0-rc2, mistakenly said 2.3.0 in earlier post

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Embed an iframe into a page Link to this post

    If you don't need the iframe to be inside your text-content, but rather at the beginning or bottom of the page, you could simply create a special Page-Type for this scenario.

    class EmbedPage extends Page
    {
       public static $db = array(
          'EmbedCode' => 'HTMLText'
       );
       
       public function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab('Root.Content.Main', new TextareaField('EmbedCode', 'Embed Code'));
          return $fields;
       }
    }

    class EmbedPage_Controller extends Page_Controller {}

    In the CMS you'll get a TextArea where you can paste your iframe code.
    In the template you just add $EmbedCode below or above your content. For example:

    <div class="typography">
       <h2>$Title</h2>
       $Content
       $EmbedCode
    </div>

  • sonicparke
    Avatar
    74 Posts

    Re: Embed an iframe into a page Link to this post

    Thanks! This helped me out a lot!

  • ste
    Avatar
    Community Member
    8 Posts

    Re: Embed an iframe into a page Link to this post

    Just updated SS to 2.3.2 and you can embed a iframe through the edit html source button.

    Thanks SS team and others.

    Ste

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