Jump to:

23355 Posts in 17873 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » SS Removing Closing <iframe> Tag From TextField

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
Go to End
Author Topic: 4478 Views
  • Liam
    Avatar
    Community Member
    470 Posts

    SS Removing Closing <iframe> Tag From TextField Link to this post

    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?

  • senica
    Avatar
    Community Member
    18 Posts

    Re: SS Removing Closing <iframe> Tag From TextField Link to this post

    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!

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: SS Removing Closing <iframe> Tag From TextField Link to this post

    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.

  • senica
    Avatar
    Community Member
    18 Posts

    Re: SS Removing Closing <iframe> Tag From TextField Link to this post

    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!

  • ayyurek
    Avatar
    Community Member
    41 Posts

    Re: SS Removing Closing <iframe> Tag From TextField Link to this post

    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
    );

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: SS Removing Closing <iframe> Tag From TextField Link to this post

    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

  • dendeffe
    Avatar
    Community Member
    135 Posts

    Re: SS Removing Closing <iframe> Tag From TextField Link to this post

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

  • neilcreagh
    Avatar
    Community Member
    90 Posts

    Re: SS Removing Closing <iframe> Tag From TextField Link to this post

    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

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