{"id":477,"date":"2019-03-27T17:02:57","date_gmt":"2019-03-27T16:02:57","guid":{"rendered":"https:\/\/asdw.de\/scriptcase-und-tinymce-mit-benutzerdefinierten-init-parametern\/"},"modified":"2019-03-27T17:16:40","modified_gmt":"2019-03-27T16:16:40","slug":"scriptcase-und-tinymce-mit-benutzerdefinierten-init-parametern","status":"publish","type":"post","link":"https:\/\/asdw.de\/en\/scriptcase-und-tinymce-mit-benutzerdefinierten-init-parametern\/","title":{"rendered":"Scriptcase and tinyMCE with userdefined init parameter"},"content":{"rendered":"<h2>Call tinyMCE in Scriptcase with your init-Settings<\/h2>\n<p>tinyMCE is a HTML editor plugin which can be used in own code.<\/p>\n<p>Scriptcase already uses tinyMCE already to show and edit text\/blob database fields with HTML formatting.<br \/>\nThe developer can set several parameters for this, but not all, especially no plugins.<\/p>\n<p>You could import another copy of tinyMCE and call the init for this.<br \/>\nDoing so, you&#8217;ll also have to take care of, when you deoply the application on a live server.<\/p>\n<p>But there is an other way:<br \/>\nUse a standard text-field in Scriptcase, which is bound to a text(blob-field in the sql table.<br \/>\nThen convert this field into a tinyMCE-editor. For this we&#8217;ll need the id of the text field. You can get this for example in Chrome via the explore feature.<\/p>\n<p>To do the conversion, add the following code into the onLoad event of the form:<\/p>\n<pre class=\"lang:php decode:true\" title=\"tinyMCE in Scriptcase einbinden\">$prodFolder = $_SESSION['scriptcase']['tinymce_test']['glo_nm_path_prod'];\r\n$tinyFolder = $prodFolder.\"\/third\/tiny_mce_new\/js\/tinymce\/\";\r\n\r\n\/\/ Declare tinyMCE - the one in Scriptcase\r\n$msg = \"&lt;script src='\".$tinyFolder.\"tinymce.min.js'&gt;&lt;\/script&gt;\";\r\n\r\n\/\/ Install tinyMCE with plugins\r\n$msg.= \"&lt;script&gt;\";\r\n$msg.= \"tinymce.init({ \";\r\n$msg.= \"selector: '#id_sc_field_text_1',\";\r\n$msg.= 'mode: \"textareas\",';\r\n$msg.= 'theme: \"modern\",';\r\n$msg.= 'browser_spellcheck : true,';\r\n$msg.= 'relative_urls : false,';\r\n$msg.= 'remove_script_host : false,';\r\n$msg.= 'convert_urls  : true,';\r\n$msg.= \"language : 'de',\";\r\n$msg.= 'statusbar : false,';\r\n$msg.= \"menubar : 'file edit insert view format table tools ',\";\r\n$msg.= \"plugins : 'advlist,autolink,link,image,lists,charmap,print,preview,hr,anchor,pagebreak,searchreplace,wordcount,visualblocks,visualchars,code,fullscreen,insertdatetime,media,nonbreaking,table,directionality,emoticons,template,textcolor,paste,textcolor,colorpicker,textpattern,contextmenu',\";\r\n$msg.= 'toolbar1: \"undo,redo,separator,styleselect,separator,bold,italic,separator,alignleft,aligncenter,alignright,alignjustify,separator,bullist,numlist,outdent,indent,separator,fullpage,link,image,template\",';\r\n$msg.= 'content_style: \".mce-container-body {text-align: center !important}\" });';\r\n$msg.= \"&lt;\/script&gt;\";\r\n\r\necho $msg;  \r\n<\/pre>\n<p>Please replace the name of the text field in this code.<br \/>\nOur sample uses a text field named\u00a0id_sc_field_text_1<br \/>\nReplace this name with the name of your text field.<\/p>\n<p>Now you can add additional functions and plugin calling tinyMCE.<\/p>\n<p>Here are two samples (please add the code before:\u00a0$msg.=&#8217;content_style&#8230; einf\u00fcgen)<\/p>\n<pre class=\"lang:php decode:true\" title=\"Es k\u00f6nnen auch Images mit CTRL\/V eingef\u00fcgt werden\">$msg.= 'paste_data_images: true,';   \/\/ Paste Images into the html\r\n<\/pre>\n<p>or define own templates to be inserted at the cursor position in tinyMCE:<\/p>\n<pre class=\"lang:php decode:true \" title=\"Benutzerdefinierte Templates einf\u00fcgen\">$msg.= 'toolbar: \"template\",';\r\n$msg.= \"templates: [{title: 'Some title 1', description: 'Some desc 1', content: 'My content'},{title: 'Some title 2', description: 'Some desc 2', url: 'http:\/\/asdw.de'}],\";\r\n$msg.= \"toolbar_items_size: 'small',\";<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Call tinyMCE in Scriptcase with your init-Settings tinyMCE is a HTML editor plugin which can be used in own code. Scriptcase already uses tinyMCE already to show and edit text\/blob database fields with HTML formatting. The developer can set several<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/asdw.de\/en\/scriptcase-und-tinymce-mit-benutzerdefinierten-init-parametern\/\">Read more &#8250;<\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":2,"featured_media":474,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[55],"tags":[134,135,137],"_links":{"self":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/477"}],"collection":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/comments?post=477"}],"version-history":[{"count":2,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/477\/revisions"}],"predecessor-version":[{"id":479,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/477\/revisions\/479"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/media\/474"}],"wp:attachment":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/media?parent=477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/categories?post=477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/tags?post=477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}