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, Ed, biapar, Willr, Ingo, swaiba

Couldn't add multiple iframes in my CMS page from admin panel

Go to End

4 Posts   1329 Views


Community Member, 2 Posts

5 June 2012 at 3:19pm


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="" /></iframe></p>

<p><iframe width="100%" height="166" scrolling="no" frameborder="no" src=""></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);

BUT it didn't worked with me.

Thanks in advance

Attached Files

Community Member, 56 Posts

5 June 2012 at 9:47pm

Edited: 05/06/2012 9:59pm

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.


<% control IframeURLs %>
<% end_control %>

Just my 2 cents. :)


Community Member, 2 Posts

6 June 2012 at 2:00pm

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

<div id="Layout">

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


Community Member, 56 Posts

6 June 2012 at 6:09pm

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: