-
- jimfraseruk

-
Total Posts: 2
Joined: 2008-08-22
|
Part two
CMS pages.
Replace the whole finction. I had to use the timeout function in this code rather than the window load used in the code above. I also could not figure out how to pre populate the page_content text area from this file so we have to change another one after this to make it work.
lib/Varien/Data/Form/Element/Editor.php
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="<yourdomian>/magento/js/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> setTimeout(function(){ tinyMCE.init({ mode : "exact", theme : "advanced", strict_loading_mode : true, elements : "'.$this->getHtmlId().'", 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">\' }); }, 1000); </script>';
/*plugins : "inlinepopups,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,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"*/
$html.= $this->getAfterElementHtml(); return $html; } else { return parent::getElementHtml(); } }
remember to change the path to TinyMCE (replace <yourdomain> with your domin) fully qualified. I also don’t think you need to the ‘$element = ....’ line but for now its fine. To pre populate the page_content text area and allow editing and saving change this last file after the first </script> tag:-
magento/app/design/adminhtml/default/default/template/page/head.phtml
<script language="javascript" type="text/javascript"> window.onload = function() { if(document.getElementById('page_content')){ if(document.getElementById('page_content').value == ''){ document.getElementById('page_content').value = "<p>Enter CMS content</p>"; } } } </script>
Hope this helps you. I have yet to use the editor extensively as I am not capturing content yet so there may be other issues.
I am using PHP 5.2.1 Magento 1.1.2 and apache 2.0.x
|