CFG Widget Framework
The goal of the widget framework is to provide an extendable widget platform. A single widget can be easily extended to provide multiple data-bindable HTML views without the expense of an XML transformation. This is achieved by separating out the widget’s three basic components of supplied data, internal data gathering and output data into distinct user controls. It is then possible to “plug-in” different components so that new HTML views are possible with little extra effort on the part of the developer.
The widget begins with the base widget user control that will reside within the site’s Widgets directory. This control will contain the necessary IWidget class inheritance and a Multiview control, as all standard widgets have. The base widget will be responsible for internal data gathering and will store any widget data passed to it from the edit mode user control. The workflow for this widget is as follows: It will store the data from the edit mode user control, gather any additional information from the CMS, and pass data structures to the appropriate view mode user control. The view mode control is determined by a selection in the edit mode. It will be dynamically added to the base widget’s view mode when the widget is loaded on a page. All supporting files for this widget will be stored within a folder structure with the same name as the widget.
The edit mode user control will reside within the Widgets\\Edits folder and will be responsible for gathering all the relevant information that the base widget requires to collect the data structures from the CMS. This includes the view information that the base control needs to be able to switch upon. The view information will be supplied via a dropdown menu. An edit mode user control will be placed upon the base widget’s Edit view and will be accessed as a traditional widget. The data it collects will be passed to the base widget when the base widget’s Save button is clicked.
The view mode user control will reside within the Widgets\\Views folder. This control will have a Src attribute used by the base widget to pass the data that it collects to the view mode control. The view mode control will only be responsible for data-binding the data it gets through its Src property and displaying the appropriate HTML. Different outputs would be represented by different user controls which accept the same type of data structure but bind the data in different HTML views. All the .ascx files that reside within the Widget’s Views folder will be available via a dropdown list in the edit mode. A reference to the View’s user control must be placed on the base widget so that it can be programmatically added when the widget’s output is rendered.
The advantages of this method will be that lightweight data-binding tools such as asp repeater controls and asp listview controls can be utilized instead of costly XML transformations. Adding outside HTML elements within the data-bindable controls is much easier and more “light-weight” than adding additional data to an XML structure before transformation.