How to enable wysiwyg by default on textarea in admin?
Asked Answered
M

2

3

How can I enable wysiwyg by default on textarea? I mean, I do not want to click on the wysiwyg button to display the area with tinyMCE :

Wysiwg

I want this directly :

enter image description here

Maidy answered 30/11, 2013 at 19:55 Comment(0)
G
7

After a little research i found it.

1) Put this code in the .phtml file you want the editor to appear directly.

2) In the 6th line of the code you can see elements: "short_description". You can change "short_description" with the element id you want. You can add more than one element id separated with comma and without spaces.

Example: I put this code in app/design/adminhtml/default/default/template/catalog/product/edit.phtml because i want the editor to appear directly when i edit product's description, short description etc.

The code:

<script type="text/javascript">
window.onload=function()
{
   tinyMCE.init({
    mode : "exact",
    elements: "short_description",
    theme : "advanced",
    plugins : "inlinepopups,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
    theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,|,visualchars,nonbreaking",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_path_location : "bottom",
    extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
    theme_advanced_resize_horizontal : 'true',
    theme_advanced_resizing : 'true',
    apply_source_formatting : 'true',
    convert_urls : 'false',
    force_br_newlines : 'true',
    doctype : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'

  });
};
</script>
Gissing answered 1/12, 2013 at 1:28 Comment(3)
Thank you a lot for your search ! It can work on product page, but how to do on category pages? And maybe there is a better way to do this ! Like on CMS pages, the wysiwyg is directly on textarea.Maidy
For the category pages do the same. Add this code in the bottom of the /app/design/adminhtml/default/default/template/catalog/category/edit.php And add elements: "group_4description". Indeed there is another way. Magento instantiates the wysiwyg in the CMS pages like $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);. But if you want to modify how it will display (add/remove plugins, themes, etc) use the code i gave you.Magento uses exactly this code in another spot.Gissing
This solution works as expected. However, how can I get the textarea value, which has the editor above it, using javascript? Edit: Solved it! Had to do a little digging! tinyMCE.get('short_description').getContent();Emulsifier
S
0

http://www.blog.magepsycho.com/how-to-use-wysiwyg-editor-tinymce-in-custom-admin-magento-module/

Add your wysiwyg Editor by default on textarea for cutome field custom

Stillman answered 6/2, 2015 at 14:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.