This library helps using UWA-Widgets from Netvibes on your PHP-page. It uses the now-recommended IFrame method.
Features
- Custom configuration menu
- Dynamic height resizing
- Simple API
- Configurable header
Usage
Basic usage
- Copy uwawidget.php somwhere you can include it from your application.
- Copy proxy.html somewhere in the web-accessible part of the server. This file manages the communication between the widget and your page.
- In your code, require_once the uwawidget.php file.
- To create a new uwawidget-object in your code, you need at least the following information:
- Create the uwawidget-object: $uwawidget = new uwawidget($widgetURL, proxyHtmlUrl);.
- Print the needed HTML on your page and you are done: echo $uwawidget->getHtml();.
Custom configuration menu
You can hide the widget-header with the edit-menu if you provide false as thirth parameter of the uwawidget-constructor. You need to provide your own configuration form in this case. You get an array of label/input-html pairs if you call $uwawidget->getPreferencesHtml(). There are two top-arrays: visible for fields you should display as input-fields and hidden for hidden form fields. See example.php for the detailed usage.
If the configuration form is submitted, you can call the uwawidget with the submitted data: $uwawidget->setAndValidatePreferencesData($_POST['uwawidgetdata']). getHtml() automatically submits these values to the widget.
Troubleshooting
Data entered into the widgets is not shown if the page is reloaded.
If the authetication in a widget is not handled by cookies or a login, there is not much that can be done. It looks like the netvibes dashboard handles the saved datasets and provides these to the widget. No dashboard, no saved data, just default-values.
Helper functions
getMetaData() returns all meta data known for the widget, getMetaDataHtml() prints this information nicely for debugging purposes.
Further Help
See a demo on oncode.info. The Library is used in the Moodle UWA Widget Block.
Downloads