Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: Add Widget tool onto product and category WYSIWYG

On the WYSIWYG editor for CMS pages in Magento there's a tool to add Magento widgets to the editor. I'd like this also to be available for the WYSIWYG on the product and category descriptions.

I'm struggling to find where the editor is even loaded at the moment. Could anyone let me know what I might have to do or at least point me in the right direction?

Thanks in advance.

enter image description here

like image 246
Adam Moss Avatar asked Dec 15 '22 15:12

Adam Moss


2 Answers

After enabling add_widgets and add_variables in class Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg_Content as per @David Manner's answer, you will likely find that whilst this will certainly enable these in the WYSIWYG editor and function properly, it will only render the raw widget/variable code in the front end (rather than the appropriate markup).

You can fix with the following:-

Navigate to /app/design/frontend/package/theme/template/catalog/category/view.phtml

Find <?php if($_description=$this->getCurrentCategory()->getDescription()): ?>

Add the following below this line:-

<?php 
    $helper = Mage::helper('cms'); 
    $processor = $helper->getPageTemplateProcessor(); 
    $_description = $processor->filter($_description); 
?>

This will render in the frontend correctly then.

like image 157
zigojacko Avatar answered Dec 28 '22 07:12

zigojacko


Under the class Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg_Content there are two flags in the config array 'add_widgets' and 'add_variables'. Both of these are set to false by default.

Setting these to true will then be caught in the Mage_Widget_Model_Observer class function prepareWidgetsPluginConfig on the event cms_wysiwyg_config_prepare.

I would suggest rewriting the Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg_Content to fit your needs, but setting add_widgets and add_variables to true should work for both categories and products.

like image 45
dmanners Avatar answered Dec 28 '22 06:12

dmanners