Skip to content

mageprofis/MageProfis_WidgetArray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MageProfis WidgetArray Extension

Dynamic widget fields

Facts

Description

This is not a widget itself, but a useful addition to the Magento widget ecosystem. By installing this extension you can use dynamic fields within your own widgets.

Usage

In your widget.xml you can use this extension as a helper block:

<!-- Widget XML defintion -->
            <items>
                <visible>1</visible>
                <label>Items</label>
                <type>array</type> <!-- Use "array" type -->
                <helper_block>
                    <type>mp_widgetarray/adminhtml_widget_array</type>
                    <data>
                        <columns>
                            <text translate="label">
                                <label>Text</label>
                            </text>
                            <col2 translate="label">
                                <label>Col 2</label>
                            </col2>
                        </columns>
                    </data>
                </helper_block>
            </items>
<!-- Widget XML defintion -->

The values are stored as a base64 AND json_encoded string, so in your widget block class you need to use base64_decode and json_decode.

<?php

class Namespace_Module_Block_Widget_YourWidget
extends Mage_Core_Block_Template
implements Mage_Widget_Block_Interface
{
    /**
     * Get items
     *
     * @return array
     */
    public function getItems()
    {
        $b64 = $this->getData('items');
        $json = base64_decode($b64);

        return json_decode($json, true);
    }
The result

The result will look similar to this, depending on the columns you've configured in your widget.xml:

Widget usage example

Compatibility

  • Magento >= 1.9 (untested, but should work in 1.7 as well)

Support

If you have any issues with this extension, open an issue on GitHub.

Contribution

Any contribution is highly appreciated. The best way to contribute code is to open a pull request on GitHub.

Developer

Volker Thiel

Licence

OSL - Open Software Licence 3.0

Copyright

(c) 2016 MageProfis

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors