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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   1945 Views

Avatar
sanjeevsingh

Community Member, 2 Posts

5 June 2012 at 3:19pm

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
Avatar
cuSSter

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.

example:

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

Just my 2 cents. :)

Avatar
sanjeevsingh

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\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

Avatar
cuSSter

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: http://doc.silverstripe.org/sapphire/en/tutorials/5-dataobject-relationship-management