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.

General Questions

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

Embed an iframe into a page


Reply

7 Posts   5763 Views

Avatar
freefor

11 March 2009 at 10:55pm Community Member, 1 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

Avatar
wdi2

18 March 2009 at 3:24am Community Member, 10 Posts

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

Avatar
ste

19 March 2009 at 2:49am Community Member, 8 Posts

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

Avatar
wdi2

20 March 2009 at 10:37am (Last edited: 20 March 2009 10:42am), Community Member, 10 Posts

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

Avatar
banal

4 April 2009 at 6:06am Community Member, 901 Posts

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>

Avatar
sonicparke

12 July 2009 at 2:04pm 74 Posts

Thanks! This helped me out a lot!

Avatar
ste

20 July 2009 at 12:35am Community Member, 8 Posts

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