0

I'm creating a custom magento widget with the WYSIWYG editor as a widget option.

I followed those two pages as initial setup http://www.behrendt.io/2013/04/12/using-a-wysiwyg-editor-in-a-magento-widget/ https://stackoverflow.com/questions/15767894/magento-add-wysiwyg-editor-to-custom-widget/15953843#15953843

Currently I see the editor appearing, but by saving the widget I run into some errors.

First of all there is the text attribute missing in the widget declaration

{{widget type="widgetone/slideshow"}}

When i try to save the widget i get the following javascript alert

enter image description here

I already looked in the web but didn't found anything helpful.

I'm using magento CE 1.7.0.2 and here you can see my widget code:

widget.xml

 <company_widgetone_slideshow type="widgetone/slideshow" translate="name description">
    <name>Slideshow</name>
    <description type="desc">Description</description>
     <parameters>
     <text translate="label">
        <label>Text</label>
        <visible>1</visible>
        <type>widgetone/widget_wysiwyg</type>
    </text>
    </parameters>
</company_widgetone_slideshow>

My widget block

class Company_WidgetOne_Block_Widget_Wysiwyg extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element {
public function render(Varien_Data_Form_Element_Abstract $element)
{

    Mage::log("block");
    $editor = new Varien_Data_Form_Element_Editor($element->getData());

    // Prevent foreach error
    $editor->getConfig()->setPlugins(array());

    $editor->setId($element->getId());
    $editor->setForm($element->getForm());

    $editor->setWysiwyg(true);
    $editor->setForceLoad(true);

    return parent::render($editor);
} }

If i try to override the magento Widget Model (as showen in the second link above)

class Company_WidgetOne_Model_Widget extends Mage_Widget_Model_Widget {
public function getWidgetDeclaration($type, $params = array(), $asIs = true)
{
    Mage::log($params);

    if( preg_match('~(^widgetone/slideshow)~', $type) )
    {
        $params['text'] = str_replace('"', "'", $params['text']);
    }

    return parent::getWidgetDeclaration($type, $params, $asIs);
}
}

The $params array is always empty ..

Also the post-parameter parameters[text]in the ajax call when saving the widget is empty

enter image description here

Please provide any possible idea you have to solve this issue

Thanks !!

1

It is not a direct answer to your question but in the past when I have needed the user to be able to include html via the widget tool what I have done is to include cms blocks using the built in block chooser. Then the user can simply add the block and then link it in via the widget.

I know that this could be a pain as the user has to use two different systems but then in my opinion you get a smoother system as a lot of our users have issues with widgets and loosing the content of widgets.

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.