Jump to:

22977 Posts in 11742 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Couldn't add multiple iframes in my CMS page from admin panel

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
Go to End
Author Topic: 620 Views
  • sanjeevsingh
    Avatar
    Community Member
    2 Posts

    Couldn't add multiple iframes in my CMS page from admin panel Link to this post

    Hi

    I need to add multiple iframes in my music page. I want it to be done from admin panel. I added these lines clicking edit HTML source of the editor but greater than and less than sign are replaced by </p> <p><. I am newbie to silverstripe. Any help will be appreciated.

    Sample Iframes:
    <p><iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F4922141&show_artwork=true" /></iframe></p>

    <p><iframe width="100%" height="166" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F9111668&show_artwork=true"></iframe></p>

    I had done some research and tried adding these lines in mysite/_config.php
    HtmlEditorConfig::get('cms')->setOption('verify_html', 'false');
    HtmlEditorConfig::get('cms')->setOption('element_format', 'html');
    HtmlEditorConfig::get('cms')->setOption('cleanup', 'false');

    Also in mysite/code/Page.php
    public function onBeforeWrite() {
          $this->Content = preg_replace('|<iframe(.*)/>|Uims', '<iframe\\1> </iframe>', $this->Content);
          parent::onBeforeWrite();
    }

    BUT it didn't worked with me.

    Thanks in advance
    Sanjeev

    Attached Files
  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: Couldn't add multiple iframes in my CMS page from admin panel Link to this post

    Use the RAW function when calling Content field of your page, e.g. $Content.RAW

    It's better to have separate fields, or better, define a relation, that will hold these iframe URLs, and just have a control block and call the RAW function.

    example:

    <% control IframeURLs %>
    IframeURL.RAW
    <% end_control %>

    Just my 2 cents.

  • sanjeevsingh
    Avatar
    Community Member
    2 Posts

    Re: Couldn't add multiple iframes in my CMS page from admin panel Link to this post

    Thanks for the quick reply but it didn't worked with me. I added RAW in \themes\brett\templates\Page.ss as

    <div id="Layout">
       $Content.RAW
    </div>

    BUT no change at all.

    I will be thankful if you provide me a stepwise instruction to define a relation. I am a newbie in SilverStripe framework.

    Thanks in advance
    Sanjeev

  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: Couldn't add multiple iframes in my CMS page from admin panel Link to this post

    I think you would need to urldecode the source of your iframe. I tried to remove the special characters and replace them with their corresponding value and it worked just fine for me. Here's a link to a tutorial for relationship management in SS: http://doc.silverstripe.org/sapphire/en/tutorials/5-dataobject-relationship-management

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