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

< script type="text/javascript" src="http: problem in wysiwyg


Reply


6 Posts   1791 Views

Avatar
Loopy

Community Member, 20 Posts

28 January 2012 at 11:42pm

Hi everyone

I am tring to put data from a server on a partner site into my silverstripe site by putting the following into a table cell: <script type="text/javascript" src="http://gpersonal.vo.llnwd.net/api/badge/js"></script>

To do this I have tried the following without success. Can anyone offer any ideas as to how I might do this.?

I have copied the HtmlEditorConfig statement from cms/_config.php to mysite/_config.php and added the following to the HtmlEditorConfig in mysite/_config.php

form[action|accept|accept-charset|enctype|method],
option[disabled|label|selected|value],
script[src|type],
select[disabled|multiple|name|size],
input[accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value],

If I then put the following into the cell of a table using the html option in the wysiwyg editor

<table>
<tr>
<td>
style type="text/css">
#wld_badge_wrapper { border: 1px solid black; width: 420px; overflow: hidden; }
#wld_badge_inner { padding: 10px 0 10px 10px; }
.wld_badge_item { float: left; margin: 0 10px 0 0; padding: 0; }
.wld_badge_item img { border: 1px solid black; }
.wld_badge_item_detail { margin-top: 5px; font-size: 75%; width: 90px; overflow: hidden; }
.wld_badge_clear { clear: both; }
</style>
<div id="wld_badge_wrapper">
<div id="wld_badge_inner">
<script type="text/javascript" src="http://gpersonal.vo.llnwd.net/api/badge/js"></script>
<div class="wld_badge_clear" />
</div>
</div> </td>

Then press Insert

If I go back to look at html it has been changed to this:

style type="text/css"&gt; #wld_badge_wrapper { border: 1px solid black; width: 420px; overflow: hidden; } #wld_badge_inner { padding: 10px 0 10px 10px; } .wld_badge_item { float: left; margin: 0 10px 0 0; padding: 0; } .wld_badge_item img { border: 1px solid black; } .wld_badge_item_detail { margin-top: 5px; font-size: 75%; width: 90px; overflow: hidden; } .wld_badge_clear { clear: both; }
<div id="wld_badge_wrapper">
<div id="wld_badge_inner">
<script src="http://gpers.vo.llnwd.net/api/badge/js" type="text/javascript"></script>
<div class="wld_badge_clear"></div>

I have tried creating id and classes in the layout.css and calling them in the html editor but this does not seem to work either. When I do this it does not like the script statement.

Looking at the documentation for silverstripe it looks like I either need to put

<% require javascript %>

or

Requirements::javascript

somewhere, but I am not sure where.

Would this resolve my problem or is it my bad coding.

Can anyone help on this?

Paul

Avatar
IOTI

Community Member, 189 Posts

31 January 2012 at 2:32am

you could try putting

HtmlEditorConfig::get('cms')->setOption('verify_html', 'false'); // turn off html validation

in your _config.php. That might work.

Ideally you wouldn't be putting <script> tags in the wysiwyg at all though.

Alternatively you can include javascript through your pages controller

for example in Page.php

class Page_Controller extends ContentController {
function init(){
parent::init()
Requirements::javascript('http://gpersonal.vo.llnwd.net/api/badge/js');
}
}

Avatar
Loopy

Community Member, 20 Posts

31 January 2012 at 3:10am

Edited: 31/01/2012 3:27am

Thanks for the reply IOTI

I have tried your suggestion

HtmlEditorConfig::get('cms')->setOption('verify_html', 'false'); // turn off html validation

But this does not work either

I have done a lot of digging and ultimately tinymce just does not like script tags. The bug is in tinymce and looking at their website I get the feeling that they are not going to address the issue because they dont think people should be putting <script> tags into a wsyiwyg editor. The only other viable option I could think of for putting them into the page is to create the document and then manually edit the document to add the script section. However this only works if documents are stored as files. Silverstripe however stores document / article in database so editing via ftp not an option.

If I create a new page type and put your suggested code in the Newpage.php:

class Page_Controller extends ContentController {
function init(){
parent::init()
Requirements::javascript('http://gpersonal.vo.llnwd.net/api/badge/js');
}
}

Can I define the position of the output of javascript('http://gpersonal.vo.llnwd.net/api/badge/js on the page?

Avatar
IOTI

Community Member, 189 Posts

31 January 2012 at 3:17am

Loopy,

hmm, well if you are going to make a new page type, Newpage.php. You could then make a new template in your templates/layout folder called Newpage.ss. then in Newpage.ss just add

<table>
<tr>
<td>
style type="text/css">
#wld_badge_wrapper { border: 1px solid black; width: 420px; overflow: hidden; }
#wld_badge_inner { padding: 10px 0 10px 10px; }
.wld_badge_item { float: left; margin: 0 10px 0 0; padding: 0; }
.wld_badge_item img { border: 1px solid black; }
.wld_badge_item_detail { margin-top: 5px; font-size: 75%; width: 90px; overflow: hidden; }
.wld_badge_clear { clear: both; }
</style>
<div id="wld_badge_wrapper">
<div id="wld_badge_inner">
<script type="text/javascript" src="http://gpersonal.vo.llnwd.net/api/badge/js"></script>
<div class="wld_badge_clear" />
</div>
</div> </td>
</table>

where ever you want it do be. What is the script going to return anyways? Am I right in thinking you just want it to display some thing on the page?

Avatar
Loopy

Community Member, 20 Posts

31 January 2012 at 3:52am

IOTI

Thanks for the info.

Yes the script pulls in a block of thumbnail images which I want to put on the right hand side of the page about half way down.

It will be one part of the final page. To build this page should I put all of the page layout/content in the following code at the point marked INSERT NEW CODE HERE. I know that this would mean editing the newpage.ss when I want to update or change the content but I am ok with that

<body>
<div id="BgContainer">
   <div id="Container">
      <div id="Header">
          
      </div>
      
      <div id="Navigation">
         <% include Navigation %>
       </div>
       
       <div class="clear"><!-- --></div>

      <div id="Layout">
       $Layout
      </div>
      
*******INSERT NEW CODE HERE ? ******

    <div class="clear"><!-- --></div>
   </div>
   <div id="Footer">
      <% include Footer %>
   </div>
</div>

</body>

Avatar
IOTI

Community Member, 189 Posts

31 January 2012 at 3:58am

Yes, that should work.