The Embed Widgets module is undergoing several changes. As a Google Summer of Code project and my first attempt at programming in Drupal, the module became rather bloated. Too many use cases were covered and the result was that the module was not easily extendable. In recent months, Embed Widgets has been refactored with the goal of simplification and extensibility. This roadmap will outline what is done, what needs to be done, and where the module is going in the future.
- A New Approach
- In the old module, there were different 'types' of widgets: IFrame, Google Gadget, etc. However, many widget platforms actually support multiple formats (IFrame, Flash).
- The new module separates the idea of a widget format from a widget platform. A platform, such as Google Gadgets is compatible with Flash and IFrame formats. Facebook profiles, however, are only compatible with Flash widgets. (See http://www.clearspring.com/docs/tech/distribution/destinations for more examples.)
- Drawing further inspiration from the ClearSpring platform, a distinction was made between a 'widget' and a 'widget placement'. "To borrow an analogy from object-oriented programming, a widget is a class. It only really exists for the end user once it is instantiated--i.e., once it's added to a web page as an <object>, <embed> or <script> tag. Once the first instance of a widget is created (a so-called "seed"), users can get their own versions and spread them throughout the web. To continue this analogy, we call each concrete instance of a widget a placement". (http://www.clearspring.com/docs/tech/core/wid-pid)
- Essentially, a widget contains information about what content is to be displayed in the widget. A placement of that widget contains information about what platform it is being embedded and in what format.
- The old module consisted of several module. Each type of widget had its own module. Also, Embed Widgets depended on several other modules (Tabs, Color Scheme). These dependencies will be gone and the final package will consist of an API module and a UI module.
- Embed Widgets API
- Simple, but powerful API to create widgets programmatically.
- Sample Code:
$my_widget = embed_widgets_new(); $my_widget->source = embed_widgets_new_source('page', 'node/27'); $my_widget->platform = 'googlegadgets'; $my_widget->set_variable('width', 300); $my_widget->set_variable('height', 350); $my_widget->get_code(); // returns embed code
- Currently, blocks, pages, and views can be used for widget content. Developers can also specify a callback to supply content:
$my_widget->source = embed_widgets_new_source('callback', 'mymodule_widget_content');
- Widget Templates
- In the old module, the templates used to render the widget were complicated and the implementation was hack-ish.
- In the new module, template suggestions are made to the theme. By default, 'widget.tpl.php' is suggested. If the path 'node/27' is being viewed as a widget, 'widget-node-27.tpl.php' is suggested. This mimics the template suggestion scheme already used by Drupal, so themers should already be familiar with it.
- Additional Features
- Forms are now working within widgets. (Was previously the most requested feature.)
What Needs To Be Done
- Embed Widgets API
- Finish API to allow new formats and platforms to be added easily.
- User Interface
- User interface for creating and managing widgets. Much of old UI can probably be used.
- User interface for getting embed code within widget.
- Create default theme for widgets.
- Other Tasks
- Improve method for arguments to be passed to widgets. This is important for Views widgets and widgets that use callbacks to generate content.
- Additional Features
- Flash widgets! Will need to create a flash container. Parameters will also need to be passed to the flash movie. (See http://www.clearspring.com/docs/tech/widget-config/configurable-flash)
- Widget Tracking
- Track 'pageviews' of widgets and widget placements.
- Total number of child placements for widget
- Number of children of this placement
- Where was widget placed? Domain, URL
- In-Widget Configuration
- Allow parameters to be exposed to users.
- Users can configure these parameters with widget. Those parameters are stored with that widget placement.