1

I have a custom module. Inside _prepareForm I have also field editor.

$wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => true,'files_browser_window_url'=>$this->getUrl().'admin/cms_wysiwyg_images/index/'));
$fieldset->addField('my_field_name','editor',array(
            'label' => Mage::helper('mymodule')->__('Some text'),
            'name' =>  'my_field_name',
            'config'    => $wysiwygConfig,
            'required'=>true,
            'style'=>'width:400px;height:300px;'
)); 

I can insert widget inside editor and when I press Save, it is still proper recognized. But when I call that field value inside template

 $myobject->getData('my_field_name')

it will show

{{widget type="cms/widget_block" template="cms/widget/static_block/default.phtml" block_id="1"}}

instead of actual widget content.

How does Magento parse data if widget is inside, how can I show this widget once it was inserted inside editor?

3

Getting my_field_name will return you raw content from the database. You have to pass it through CMS processor:

echo Mage::helper('cms')->getBlockTemplateProcessor()->filter($myobject->getData('my_field_name'));
0
0

In your Block file you can override the _toHtml method. It is the magento filter static block and cms pages content :

protected function _toHtml()
{
    $html = parent::_toHtml();
    return Mage::helper('cms')->getBlockTemplateProcessor()->filter($html);
}

In this way it will process all your content. See in these files :

Mage_Cms_Block_Page
Mage_Cms_Block_Block

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.