You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

  Saturday, 05 January 2019
  4 Replies
  13.7K Visits
I have modified script to insert textarea into pages, I've tried using advice from link in URL but no success. I've hacked some code and got it working partially using javascript.

I'm unable to workout the correct method to initiate the editor, as such cannot obtain correct token.


try{WFEditor.init({"token":"e3ef1cc0901da29678b38b7845372236","etag":"7b00148dbc12caea4ae3866eb59daffa",


Here is what I've done so far to trouble shoot.

1) I added the script below.

// PHP code at top of page start
$editor = JFactory::getEditor();
$editor->initialise();
$conf = JFactory::getConfig();
$editor = $conf->get('editor');
// PHP code end

Added this html code
<textarea rows="4" cols="50" id="12345">
This is some text.
</textarea>

Added this JS at end of document
<script>
if (typeof tinymce !== "undefined") {
tinyMCE.execCommand('mceAddControl',false,'12345');
}
</script>

2) When viewing the page the textarea appears with no formatting, there are no errors reported.

3) Removed the script and replaced everything with this.

This is top of document
<script src="/plugins/system/jcemediabox/js/jcemediabox.js?0c56fee23edfcb9fbdfe257623c5280e"></script>
<link rel="stylesheet" href="/components/com_jce/editor/libraries/css/editor.min.css?1dc0f81e61177e396b328f023031f32d" type="text/css" />
<script data-cfasync="false" type="text/javascript" src="/components/com_jce/editor/tiny_mce/tiny_mce.js?302176056c6a6359aa948dd54323c75b"></script>
<script data-cfasync="false" type="text/javascript" src="/components/com_jce/editor/libraries/js/editor.min.js?ace0ef46b772d73cd0cc236d99c91033"></script>
<script data-cfasync="false" type="text/javascript">try{WFEditor.init({"token":"e3ef1cc0901da29678b38b7845372236","etag":"7b00148dbc12caea4ae3866eb59daffa","context":22,"base_url":"https://qyoobd.com/","language":"en","directionality":"ltr","theme":"advanced","plugins":"core,autolink,cleanup,code,format,importcss,colorpicker,upload,formatselect,styleselect,fontselect,fontsizeselect,fontcolor,clipboard,lists,textcase,charmap,hr,directionality,fullscreen,print,searchreplace,table,style,xhtmlxtras,visualchars,visualblocks,nonbreaking,anchor,link,imgmanager_ext,mediamanager,filemanager,templatemanager,caption,microdata,textpattern,spellchecker,article,browser,contextmenu,inlinepopups,media,preview,source,advlist,wordcount","language_load":false,"theme_advanced_buttons1":"help,newdocument,undo,redo,|,bold,italic,underline,strikethrough,justifyfull,justifycenter,justifyleft,justifyright,|,blockquote,formatselect,styleselect,removeformat,cleanup","theme_advanced_buttons2":"fontselect,fontsizeselect,forecolor,backcolor,|,cut,copy,paste,pastetext,indent,outdent,numlist,bullist,sub,sup,textcase,charmap,hr","theme_advanced_buttons3":"ltr,rtl,fullscreen,print,search,|,table_insert,delete_table,row_props,cell_props,row_before,row_after,delete_row,col_before,col_after,delete_col,split_cells,merge_cells,style,cite,abbr,acronym,del,ins,attribs","theme_advanced_buttons4":"visualaid,visualchars,visualblocks,nonbreaking,anchor,unlink,link,imgmanager_ext,mediamanager,filemanager,templatemanager,caption_add,caption_delete,microdata,spellchecker,readmore,pagebreak","theme_advanced_resizing":true,"content_css":"/templates/theme3079/css/template.css?1543883254","active_tab":"wf-editor-wysiwyg","schema":"mixed","invalid_elements":"script,style,applet,body,bgsound,base,basefont,frame,frameset,head,html,id,ilayer,layer,link,meta,name,title,xml","remove_script_host":false,"imgmanager_ext_upload":{"max_size":1024,"filetypes":["jpg","jpeg","png","gif"]},"filemanager_upload":{"max_size":1024,"filetypes":["pdf","doc","docx","dot","dotx","ppt","pps","pptx","ppsx","xls","xlsx","gif","jpeg","jpg","png","zip","tar","gz","swf","mov","wmv","avi","flv","mp4","ogv","ogg","webm","mpeg","mpg","wav","mp3","ogg","webm","aiff","odt","odg","odp","ods","odf"]},"spellchecker_engine":"browser","extension_id":22,"source_theme":"codemirror","compress":{"javascript":0,"css":0}});}catch(e){console.debug(e);}</script>

Then added this html code
<textarea rows="4" cols="50" id="12345">
This is some text.
</textarea>

Added this JS at end of document
<script>
if (typeof tinymce !== "undefined") {
tinyMCE.execCommand('mceAddControl',false,'12345');
}
</script>

4) The editor appears but unable to access things like inserting images/videos.
5) If I open a page with a module 'single article' then edit it
6) View page source to obtain the token and etag
7) Edit the script below, replacing the token from page source

try{WFEditor.init({"token":"TOKEN_HERE_FROM_PAGE_SOURCE","etag":"ETAG_HERE_FROM_PAGE_SOURCE"

8) The editor works as it should as long as the user session continues.

That's as far as I've got with trouble shooting. It appears that step 1 is my issue.

I can happily show you what I've done so far, I'm unsure what detail needs to be added here as it's my first post.

Regards

Stephen
more than a month ago
·
#97839
You should just use:


$editor = JFactory::getEditor();
$editor->initialise();

echo $editor->display('12345');

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#97840
If you are dynamically creating the textarea then use:


$editor = JFactory::getEditor();
$editor->initialise();


then


<script>
if (typeof WFEditor !== 'undefined') {
WFEditor.create('12345');
}
</script>

Just because you're not paranoid doesn't mean everybody isn't out to get you.

more than a month ago
·
#97845
Hi Ryan,

Thanks for your reply, I've tried this:

$editor = JFactory::getEditor();
$editor->initialise();
echo $editor->display('12345');

I get this error message:

0
TOO FEW ARGUMENTS TO FUNCTION JOOMLA\CMS\EDITOR\EDITOR::DISPLAY(), 1 PASSED IN /HOME/QYOOBD84/PUBLIC_HTML/INCLUDES/EDIT_PAGE_CONTENT.PHP ON LINE 14 AND AT LEAST 6 EXPECTED
more than a month ago
·
#97846
I then did some searching on google and found this.

$editor = JFactory::getEditor();
$editor->initialise();
$params = array( 'smilies'=> '0', 'style' => '1', 'layer' => '0', 'table' => '0', 'clear_entities'=>'0');
echo $editor->display( '12345', '', '400', '400', '20', '20', false, $params );

This is odd though.. When logged in and run the script above with an Admin user account, the editor appears but unable to access images etc (get a 404 page not found message).
  • Page :
  • 1
There are no replies made for this post yet.
Be one of the first to reply to this post!