Jump to:

22983 Posts in 11709 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » iframes and tinyMCE

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: 3737 Views
  • Chris Hope
    Avatar
    Community Member
    18 Posts

    Re: iframes and tinyMCE Link to this post

    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/

  • Lemonie
    Avatar
    Community Member
    70 Posts

    Re: iframes and tinyMCE Link to this post

    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?

  • Chris Hope
    Avatar
    Community Member
    18 Posts

    Re: iframes and tinyMCE Link to this post

    It would help if you posted the error.

  • petermeilahn
    Avatar
    Community Member
    1 Post

    Re: iframes and tinyMCE Link to this post

    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

  • socks
    Avatar
    Community Member
    190 Posts

    Re: iframes and tinyMCE Link to this post

    @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 {

    ...

    }

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