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

SS Removing Closing <iframe> Tag From TextField


Go to End
Reply


15 Posts   4765 Views

Avatar
Liam

Community Member, 470 Posts

27 May 2010 at 4:13am

So this doesn't seem to be related to TinyMCE specifically. I know there has been posts on this in the past, but this seems different unless I'm missing something.

I'm trying to embed some Google Map code to a page. I'd prefer to keep it out of the default content field, so I setup my PageType to offer a TextField to copy and paste the code.

I've had this working on older versions of SS, but when setting up a new site with 2.4, when I save/publish the page, it only removes the closing <iframe> tag, not the opening tag.

Here is what my page code looks like:

public static $db = array(
      'GoogleMap' => 'HTMLText'
   );

Then in getCMSFields()

$fields->addFieldToTab('Root.Content.Main', new TextField('GoogleMap', 'Google Map Code'), 'Content');

Then in my template for the page type, I have $GoogleMap to display the code.

As I mentioned, I have this exact setup working with a different site in SS 2.3

The reason I'm only using a TextField is that I don't need a large TextArea with the TinyMCE editor taking up so much space in the admin panel.

Any ideas on where this is being stripped out?

Avatar
senica

Community Member, 18 Posts

21 June 2010 at 3:25pm

Hey!

Did you ever figure this out? I'm having the exact same problem and it's causing another include template to not display since the iframe tag isn't closed off.

strange!

Avatar
Liam

Community Member, 470 Posts

21 June 2010 at 3:38pm

No, I just gave up and hard coded it into the template. It wasn't a huge deal as the Google Map code isn't going to change, but I wanted more control for my client in case for some odd reason they wanted to change it.

Definitely strange as unless I'm totally missing something, this exact same code worked in 2.3. I was only under the impression TincMCE strips some stuff in the default checking of code, but any other field is fine and raw. Obviously I'm wrong, but can't sort out where.

Avatar
senica

Community Member, 18 Posts

21 June 2010 at 3:44pm

Yeah, sucks. This is my first time with SS. Nice but terribly frustrating at the same time.

I've seen some old posts about editing a file that apparently doesn't exist or isn't in the same place on this newer version.

I'll keep searching. Thanks though!

Avatar
ayyurek

Community Member, 41 Posts

21 June 2010 at 9:34pm

Edited: 21/06/2010 9:38pm

It sounds strange. Maybe a better way is keeping iframe tags hardcoded in the template but keeping the src, width and height inside ss? By the way you can force TinyMCE about not to strip tags with adding the following line to _config.php. It works normal with all other tags but i am not sure about if it will strip iframe.

HtmlEditorConfig::get('cms')->setOption('verify_html', 'false');

Or maybe you can use a textareafield with one 1 row =)

new TextareaField(
$name = "description",
$title = "Description",
$rows = 1
);

Avatar
Howard

Community Member, 215 Posts

1 July 2010 at 4:59pm

I just came across this problem as well. This issue is that HTMLText values are passed through DOMDocument, which collapses tags where they are closed directly after being opened - ie: <iframe ...></iframe> gets converted to <iframe ... /> but the simple fix for this is to just add a space between the tags ie: <iframe ...> </iframe>

It then works :)

Avatar
dendeffe

Community Member, 135 Posts

2 July 2010 at 7:34pm

Hmm I'm doing something similar and use $IframeCode.RAW in my template which seems to work well.

Avatar
neilcreagh

Community Member, 97 Posts

27 November 2010 at 8:29am

I'm having this same problem, SS is automatically stripping the closing </iframe> and changing it to a self closing tag - breaking all of my page content that appears after it. Putting a space in before the closing tag works - but I don't want to have to tell my client to do this every time!

Is there a better way or can anyone suggest a solution?

My client wants to be able to embed multiple Vimeo videos onto the pages at various sizes - so he wants to control all the settings through Vimeo (rather than me hard coding the embed code onto the page). I've supplied a HTMLText box in Silverstripe for each Vimeo embed code, which works great except for this issue breaking the codes if a space isn't manually entered.

Thanks

Go to Top