-
- ijeweb

-
Total Posts: 21
Joined: 2008-05-29
|
Hi,
After trying to enable WYSIWYG (tinyMCE) and going through all the errors mentioned in this board I managed to get it working and I post here the solution. Someone might have changed the wiki with what seems to have worked for them - but I don’t think that’s the right solution for everyone so here I post my findings.
It’s a combination of solutions given around this board - and credits go to Dan, focusnet and winzippy
in the editor.php file (lib/Varien/Data/Form/Element) I inserted this code:
public function getElementHtml() { if( $this->getWysiwyg() === true ) { $element = ($this->getState() == 'html') ? '' : $this->getHtmlId();
$html = '<textarea name="'.$this->getName().'" title="'.$this->getTitle().'" id="'.$this->getHtmlId().'" class="textarea '.$this->getClass().'" '.$this->serialize($this->getHtmlAttributes()).' >'.$this->getEscapedValue().'</textarea> <script language="javascript" type="text/javascript" src="/js/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ strict_loading_mode : "true", mode : "exact", theme : "advanced", elements : "' . $element . '", 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 : "false", theme_advanced_resizing : "false", apply_source_formatting : "true", convert_urls : "true", 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>'; $html.= $this->getAfterElementHtml(); return $html; } else { return parent::getElementHtml(); } }
That function should start @ around line 49 already, just replace it.
in main.php (app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/) I inserted this code:
$fieldset->addField('content', 'editor', array( 'strict_loading_mode' => false, 'name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'width: 98%; height: 600px;', 'wysiwyg' => true, 'required' => true, 'theme' => 'advanced', ));
In edit.phtml (app/design/adminhtml/default/default/template/catalog/product) I inserted this code:
<script language="javascript" type="text/javascript" src="/js/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> Event.observe(window, 'load', function() { tinyMCE.init({ strict_loading_mode : "true", mode : "exact", theme : "advanced", elements : "description,short_description", 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>
The last problem I experienced was the blank grey area - solved by strict_loading_mode : “true”, you may need to play around with this option if you get that grey area.
BTW, I’m using the version of tinyMCE that was originally shipped with Magento - and using Magento 1.1.1 - and I’ve applied these same settings in 3 different servers and 3 different Magento instances and it has worked perfectly
Hope this helps anyone,
|