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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

iframes and tinyMCE


Go to End


13 Posts   9204 Views

Avatar
Chris Hope

Community Member, 18 Posts

12 November 2011 at 7:20pm

An alternative is to use shortcodes, something I learned about after contributing this this thread.

There's a tutorial over at SS Bits which covers YouTube as an example here: http://www.ssbits.com/tutorials/2010/2-4-using-short-codes-to-embed-a-youtube-video/

Avatar
Lemonie

Community Member, 70 Posts

16 June 2012 at 12:38am

I have followed the instructions but cannot get this to work. I have added the code to Page.php as below

<?php

class Page extends SiteTree {

public static $db = array(

);

public static $has_one = array(

);

function onBeforeWrite() {
$this->Content = preg_replace('|<iframe(.*)/>|Uims', '<iframe\\1> </iframe>', $this->Content);
parent::onBeforeWrite();
}
public function getCMSFields()
{
$fields = parent::getCMSFields();

//Remove Reports/todo tabs
$fields->removeByName("To-do");
$fields->removeByName("Reports");

return $fields;
}
}

but I just get an error when I do a dev/build?

Can anybody help?

Avatar
Chris Hope

Community Member, 18 Posts

16 June 2012 at 7:48am

It would help if you posted the error.

Avatar
petermeilahn

Community Member, 1 Post

8 August 2013 at 2:32am

Hi, I have having the same issue for trying to put a soundcloud player on my site.

Thanks everyone and Chris Hope especially for posting the below.

I can change code in the files but would really appreciate a step by step instruction on how to do this ( I do clinical counseling and dabble in free human computer education and therapy interfaces for the public but can really only do programming "labor" - trying to be a full programmer makes my head hurt sometimes):

From Chris Hope:

Re: iframes and tinyMCE Link to this post
9 May 2011 at 11:20am

Now that I've actually tried this it doesn't work as expected because the content has already been loaded into the object using domdocument so it's already collapsed the iframe. I've used this regexp instead:

function onBeforeWrite() {
$this->Content = preg_replace('|<iframe(.*)/>|Uims', '<iframe\\1> </iframe>', $this->Content);
parent::onBeforeWrite();
}

___________________

Thanks, Peter Meilahn - www.mindvolume.com

Avatar
socks

Community Member, 191 Posts

10 August 2013 at 12:44pm

@petermeilahn

Add that code here: mysite > code > Page.php


<?php

class Page extends SiteTree {
	
	// Keeps TinyMCE from messing up iframe code
	function onBeforeWrite() { 
		$this->Content = preg_replace('|<iframe(.*)/>|Uims', '<iframe\\1> </iframe>', $this->Content); 
		parent::onBeforeWrite(); 
	}

}

class Page_Controller extends ContentController {

  ...

}

Go to Top