HOW TO add WYSIWYG editor to pages in Backend

Discuss everything related to ApPHP Durecty CMF. All versions. Any questions related to the Directy CMF developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

administrator
Site Admin
Site Admin
Posts: 6011
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO add WYSIWYG editor to pages in Backend

Postby administrator » Oct 14th, '17, 14:44

Currently all wizards use only simple textareas, but you may easy turn them into WYSIWYG editor by simple customization of the page.
Example:

At the top of the script:

Code: Select all

<!-- register tinymce files -->
<?php A::app()->getClientScript()->registerScriptFile('assets/vendors/tinymce/tiny_mce.js'); ?>
<?php A::app()->getClientScript()->registerScriptFile('assets/vendors/tinymce/config.js'); ?>
<?php A::app()->getClientScript()->registerCssFile('assets/vendors/tinymce/general.css'); ?>


At the bottom of the script:

Code: Select all

A::app()->getClientScript()->registerScript(
   'setTinyMceEditorConfig',
   'tinymceConfigs[0].height = "100px";
    tinymceConfigs[1].height = "150px";',
   2
);
A::app()->getClientScript()->registerScript(
   'setTinyMceEditor',
   'setEditor("textarea_element_id_1", '.(($errorField == 'textarea_element_id_1') ? 'true' : 'false').', "simplest");
    setEditor("textarea_element_id_2", '.(($errorField == 'textarea_element_id_2') ? 'true' : 'false').', "simple");',
   2
);


where "textarea_element_id_1" and "textarea_element_id_2" are ID of textarea HTML elements, that will be turned into WYSIWYG editor.

Untitled.png
Untitled.png (29.74 KiB) Viewed 212 times

Return to “ApPHP Directy CMF {developers/users}”