21490 Posts in 5783 Topics by 2622 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 685 Views |
-
Allowing Scripts in the HTML Editor

14 June 2011 at 5:12am
Hi All,
I'm extremely new to php and SS CMS!
I am having trouble getting some scripts to work (which I am transferring from my old html website).
I have searched the forum for solutions, and so far have found that I should edit mysite/config.php to include:HtmlEditorConfig::get('cms')->setOption('extended_valid_elements',"script[type|src],img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt]");
However, my script still won't work as the CMS seems to place comments bewteen scripts with <![CDATA[ as shown here:
<script type="text/javascript" src="http://www.db798.com/pictobrowser/swfobject.js">// <![CDATA[
<script type="text/javascript">[CDATA[<![CDATA[<![CDATA[<![CDATA[// <![CDATA[
var so = new SWFObject("http://www.db798.com/pictobrowserp.swf", "PictoBrowser", "940", "590", "8", "#3a3a3a"); so.addVariable("source", "album"); so.addVariable("userName", "user"); so.addVariable("names", "101125"); so.addVariable("albumId", "0000000123"); so.addVariable("titles", "off"); so.addVariable("displayNotes", "off"); so.addVariable("thumbAutoHide", "off"); so.addVariable("imageSize", "original"); so.addVariable("vAlign", "mid"); so.addVariable("vertOffset", "0"); so.addVariable("colorHexVar", "3a3a3a"); so.addVariable("initialScale", "off"); so.addVariable("bgAlpha", "5"); so.write("PictoBrowser110419211155");
// ]]]]]]]]<![CDATA[><![CDATA[><![CDATA[><![CDATA[>]]]]]]<![CDATA[><![CDATA[><![CDATA[>]]]]<![CDATA[><![CDATA[>]]]][CDATA[
// -->]]></script>Does anybody have any ideas????
Many thanks!!!
-
Re: Allowing Scripts in the HTML Editor

27 January 2012 at 4:43am Last edited: 27 January 2012 4:44am
I know this is a old post, but i just had the same problem and found a (rather) hacky solution:
Add this to your Page.php inside the Page Class.
public function onBeforeWrite(){
parent::onBeforeWrite();
if(!empty($this->RawContext)){
$searchFor = array(
'<![CDATA[',
']]]]>>]]>',
']]>'
);
$this->RawContext = str_replace($searchFor, '', $this->RawContext);
}
}My field is "RawContext" where i used some javascript.
You should "clean" all the CDATA Tags from the field first. Then the onBeforeWrite will filter those new added tags out.
cheers
-
Re: Allowing Scripts in the HTML Editor

1 February 2012 at 3:29am Last edited: 1 February 2012 3:33am
I have had similar problem with <script type="text/javascript" src+"url" statement
Did you add this to the Page.php file at mysite/code/Page.php?
Also re RawContext, what is this?
Any help gratefully received. I have tried a number of suggestions on the forum but so far none have worked. I need to be able to find a way to use <script type="text/javascript" src+"url" statement.
If I can't do this then I will have to look at an alternative cms which would be a shame because in every other regard Silverstripe seem to be just what I need.
| 685 Views | ||
|
Page:
1
|
Go to Top |

