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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With