In Category View Page :

I have a requirement to display category description in category view page where description has some HTML formats and images with media url:

if you display the textarea field with the following code  the code included by the wysiwyg editor like src=”{{media url=”folder/image.jpg”}} has not been parsed.

Replace:

<?php echo $_description=$this->getCurrentCategory()->getDescription() ?>

With:

<?php echo $this->helper('cms')->getBlockTemplateProcessor()->filter($this->getCurrentCategory()->getDescription() )?>

To use the CMS directives like the WYSIWYG insert image in your product (or category) attributes you have to edit the template which displays the attribute and replace the code where the attribute is displayed.

For example: in /app/design/frontend///template/catalog/view/description.phtml

Replace

<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_description), 'description') ?>

with:

<?php echo $this->helper('cms')->getBlockTemplateProcessor()->filter($this->helper('catalog/output')->productAttribute($this->getProduct(), nl2br($_description), 'description') )?>

Here’s why:

In Mage_Cms_Helper_Data functions

getPageTemplateProcessor()getBlockTemplateProcessor()
use configuration nodes: 

'global/cms/page/tempate_filter''global/cms/block/tempate_filter'

to return the models to use as “processors”. Both config nodes return

'widget/template_filter'

The inheritance works like this

Mage_Widget_Model_Template_Filter extends Mage_Cms_Model_Template_FilterMage_Cms_Model_Template_Filter extends Mage_Core_Model_Email_Template_FilterMage_Core_Model_Email_Template_Filter extends Varien_Filter_Template

The function which interprets the directives is

Varien_Filter_Template::filter()

Ideally you’d want to look into using the event framework or override Mage_Catalog_Helper_Output to add this functionality to productAttribute() and/or categoryAttribute().working-on-a-computer-smiley-emoticon

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *