Custom wysiwyg text blocks aren’t parsed for variables like {{media }} in magento 1.4

Posted: July 1, 2010 in Magento

So far one big cause of the problem is that the configuration for the Wysiwyg on custom fields is different than that on CMS/Product Description fields. In particular the Varien Widget menu options are not included.

If these are missing then the bug is exposed, in js/mage/adminhtml/wysiwyg/tiny_mce/setup.js the beforeSetContent and saveContent methods incorrectly assume that widgets have to be configured before it will process directives.

beforeSetContent: function(o) {
o.content = this.encodeDirectives(o.content); //add
if(this.config.add_widgets) {
o.content = this.encodeWidgets(o.content);
//o.content = this.encodeDirectives(o.content); // removed

saveContent: function(o) {
o.content = this.decodeDirectives(o.content);//add
if(this.config.add_widgets) {
o.content = this.decodeWidgets(o.content);
//o.content = this.decodeDirectives(o.content); // removed

Still to do
1) you can still stuff things up if you show the editor, then press submit when its still showing – even though the saveContent method gets called it no longer functions correctly, so I suspect the wrong object is being passed to it in this sequence…this is where I’m currently stuck, any suggestions most welcome!
2) custom wysiwyg text blocks currently aren’t parsed for variables like {{media }} or {{skin }} so it needs to be generically extended to cope with that, or filtered in the .phtml file that renders it.
The filter for a custom attribute is of the form:

$_cmsHelper = Mage::helper('cms');
$_process = $_cmsHelper->getBlockTemplateProcessor();
echo $_process->filter($_product->getMyCustomAttribute()); //pass the variable which is use to display content of wysiwyg editor

Bijal Bhavsar 🙂

  1. Rees says:

    nice bit of code! 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s