rayamedia/yima-widgetator

There is no license information available for the latest version (dev-master) of this package.

Widgetator layout module.

Installs: 19

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yima-core-module

dev-master 2015-06-24 17:44 UTC

This package is auto-updated.

Last update: 2024-04-24 04:15:32 UTC


README

this module is part of Yima Application Framework

See it in action

What is widget

Widget is a class that implement minimal interface WidgetInterface

interface WidgetInterface
{
    /**
     * Render widget as string output
     *
     * @return string
     */
    public function render();
}

Widget plugin manager

Widgets stored in widget plugin manager (serviceLocator for widgets). stored with serviceManager key yimaWidgetator.WidgetManager and build as factory service.

Define widget(s) from merged config

return array(
    /**
     * Register Widgets in WidgetManager
     *
     * each widget must instance of WidgetInterface
     */
    'yima_widgetator' => [
        // This is configurable service manager config
        'services' => [
            'invokables' => [
                # 'widgetName' => 'Widget\Class',
            ],
            'initializers' => [
                // DB: Using Global db Adapter on each services Implemented AdapterAwareInterface
                function ($instance, $sl) {
                    if ($instance instanceof \Zend\Db\Adapter\AdapterAwareInterface) {
                        $sm = $sl->getServiceLocator();
                        $instance->setDbAdapter(
                            $sm->get('Zend\Db\Adapter\Adapter')
                        );
                    }
                }
            ],
        ],
        'widgets' => [
            /** @see RegionBoxContainer */
            'region_box' => [
                # // $priority default is start with 0
                # $priority => 'WidgetName',
                # $priority => [
                #    'widget' => 'WidgetName'
                #    'params' => [
                #       'with_construct_param' => 'param_value'
                #     ]
                # ],
            ],
        ],
    ],

How to Get Widgets From ?

In Controller with controller helper:

$this->layout()->side_bar = $this->widget('widgetName')->render();

In View Script:

<div class="container">
    <p><?php echo $this->widget('widgetName')->render();?></p>
</div>

Load Widgets With Ajax Call

ajax widget loading need some js resources you can find in www folder of module, you can put file anywhere you want and edit config\module.config.php.

return array(
    /**
     * Libraries that used in Ajax Loading of widgets.
     * @see \yimaJquery\View\Helper\WidgetAjaxy
     */
    'static_uri_helper' => array(
        'Yima.Widgetator.JS.Jquery.Ajaxq' => '$basepath/js/yima-widgetator/jquery.ajaxq.min.js',
        'Yima.Widgetator.JS.Jquery.Json'  => '$basepath/js/yima-widgetator/jquery.json.min.js',
    ),

for more info around static_uri_helper see yimaStaticUriHelper

In View Script:

<div class="container">
    <p id="container_id">
        <?php
        echo $this->widgetAjaxy('widgetName',   // widget name
            array('option' => 'value'),         // options
            'container_id',                     // id of dom element
            'function callback(response)'       // callback after loading widget
            );
        ?>
    </p>
</div>

I`m working to improve ajax loading of widgets.

And Finally

We have some Abstract class for widgets called: AbstractWidget and AbstractMvcWidget. (take a look)

Todo

Example Widgets and AbstractClasses will be added.

Installation

Requirement

Composer installation:

require rayamedia/yima-widgetator in your composer.json

Or clone to modules folder

Enable module in application config

Support

To report bugs or request features, please visit the Issue Tracker.

Please feel free to contribute with new issues, requests and code fixes or new features.