Simple Widget VS Widget Type - Documentation topics on: simple widget,simple widget vs widget structure,widgets,widget structure type,.

Simple Widget VS Widget Type

As a best practice, Widget Types should created when one piece of code will be re-used many times throughout a site with small code variations between each usage.  Rather than re-writing widgets with redundant code in them, all options for changing the content pull should be added as configurable fields to a formal Widget Type. Widget Type field values can be passed as parameters to the dynamic code so that users, who do not know HTML or velocity, can provide parameters for the variations of the dynamic pull.  For example, if news listing/detail pages need to be created for many departments or organizations, then a Widget Type could be created and all the variations for each dept/organization could be accounted for as fields in the Widget Type.  Content contributors within each department/organization could then simply customize their own news pull simply by using checkboxes, select boxes, radio buttons, categories, etc., to customize a dynamic pull of news in the form of a widget without knowing any HTML or velocity.  Widget Types must be added from the Content Types tab and require a little more setup time and planning than a simple widget.  Clicking "Edit Widget" on any Widget Type, aside from a simple widget, will only expose the custom widget fields or parameters for the dynamic pull, but not the code field from the Widget Type.  This can only be edited, by editing the Widget Type itself. This code field in the Widget Type should handle the settings of the extra fields added to the Widget Type and change the pull, based on those field options set by the widget creator.

<em>Widget Type</em> Fields

A Simple Widget, however, is very quickly implemented and may be a better choice when the dynamic code being placed on the page is small and more singular in it's intended usage.  If a piece of code will not be re-used or have several variants, then a simple widget is more expedient and can be added directly to a content container on a backend HTML page.  The simple widget has only one dynamic code field and does not (by default), allow parameters to be set on the widget.  Simple widgets expose the their dynamic code field for editing directly from the "Edit Widget" link on an HTML page.

Simple Widget Code