View more context

 

rista

in case of moving them to wrong place

rista

or you can make a validator for that one that will be checking if it's in the right parent class

LiamC

We have a client that want to embed <script> code in the CMS for his social media curator accounts which is fine but I cant get it to render as HTML , it just shows the code rather than rendering. Anyone got any ideas please?

LiamC

Sorry I am not to sure what that is, I have tried the HTMLText field using embed source?

LiamC

Sorry tinymce is WYSIWYG in that case yes I am

robbieaverill

hang on - you're trying to embed a script tag in tinymce or is a separate field?

LiamC
  1. <script type="text/javascript">
  2. /* curator-feed */
  3. (function(){
  4. var i, e, d = document, s = "script";i = d.createElement("script");i.async = 1;
  5. i.src = "https://cdn.curator.io/published/b54c3375-7ee1-41e3-8522-d3c1b6cf935a.js";
  6. e = d.getElementsByTagName(s)[0];e.parentNode.insertBefore(i, e);
  7. })();
  8. </script>
robbieaverill

and you're pasting that directly into the wysiwyg editor, or are you inserting it via the "source code" view of the editor?

LiamC

He wants to add the above through the CMS but I cant get it render it just shows as you read it above

robbieaverill

ok - pasting directly into the editor would convert everything to escaped HTML because it's meant to be a text entry form

robbieaverill

you'd need to open the source code view and paste it there

robbieaverill

BUT tinymce would remove script tags by default, so you'll need to allow them

robbieaverill

see https://stackoverflow.com/a/24614829/2812842

Show 1 attachment(s)
Stack Overflow  
Script tags in TinyMCE fields are not saving correctly

I am running tinyMCE on my site and I'm trying to insert script tags. I am trying to insert my script tags into the body of the source of the tinyMCE instance. However, when I do I get problems. ...

Hide attachment content
LiamC

Yeah soon as I save it inside source code view it clears it

LiamC

that link should help me then , thank you

robbieaverill

here's an example for how to enable it in SS: https://github.com/silverstripe/silverstripe-admin/blob/1/_config.php#L34

Show 1 attachment(s)
_config.php:34

        'extended_valid_elements' =&gt; "img[class|src|alt|title|hspace|vspace|width|height|align|name"
Hide attachment content
robbieaverill

so

  1. TinyMCEConfig::get('cms')
  2. ->setOptions([
  3. 'extended_valid_elements' => 'script[language|type|src]'
  4. ]);
LiamC

Thank you - Do I use that code in _config.php or the class im trying to embed the script?

robbieaverill

you'd be better to add a CuratorURL textfield to your page, allow them to put https://cdn.curator.io/published/b54c3375-7ee1-41e3-8522-d3c1b6cf935a.js into it, then render the rest of the script tag in a template and insert the URL

LiamC

Yeah I also tried that but it breaks curator for some reason

robbieaverill

ok, well whichever way works for you is fine, but that'd be my suggestion - otherwise you're allowing anyone with CMS edit access to insert arbitrary javascript into any page on the site

LiamC

I'll give both a go, thank you for your help 🙂

robbieaverill

FYI we do something similar to this with an A/B tester tool on http://silverstripe.org, TextField in the CMS for the URL and insert the rest of the script tag in a template if it's set. also common with google analytics tracking code - enter your code and then render the rest of the snippet in a template if it's set

LiamC

Okay thank you I will check that out 🙂

nils

+1 you really want this to go in the template and add plain text variables through the CMS


Show less replies
lerni

How should I migrate elemental elements from elemental 1.x to 3.x (SS 3.x vs. 4.x)?

Probable it needs some remapping but is there a migration Task to reflect that BaseElement now extends now DO instead of Widget?

  1. SilverStripe\ORM\DatabaseAdmin:
  2. classname_value_remapping:
  3. ElementalArea: DNADesign\Elemental\Models\ElementalArea
  4. BaseElement: DNADesign\Elemental\Models\BaseElement
robbieaverill

have you tried something and had problems? I would've thought that dev/build with the legacy classname remapping config would've done most of the work for you

lerni

migration runs trough but elements are all gone or not associated how they should.

lerni

I thought they are missing because of BaseElement vs. Widget