Widgets are the primary way of adding content to Layouts. In the most basic sense a widget is a consistent element that can be used to display some pre-defined content or add dynamic functionality to a page. This can be anything from adding in simple text or images to communicating with a Point of Sale (POS) system to add items to a user's e-cart. The widget system allows developers to create whatever functionality they need to add to a page without requiring a content editor to have a programming background to use or work with.
Widget functionality was designed to be extended. Their design allows developers to build in any functionality required for part of a page. Since some functionality may require additional properties each widget is given two types of properties to help configure their functionality.
Custom properties allow for a content editor to modify the content or functionality of a widget in a pre-defined way. This could include changing the asset used on an asset widget or modifying the text of the text widget. It could also include more complex properties such as configuring api keys for communication with a 3rd party api or adding restrictions to a page based on a user's login credentials. These types of custom properties differ from system properties which include changing some information common to every widget such as HTML ID/Classes. The functionality provided by a widget is only limited by its design.
Editing widgets is a simple process:
- Open the widget edit area
- From the Layout Editor Content area
- Click on the widget
- Click the orange pencil icon to open up the widget edit panel from the sidebar.
- From the sidebar
- Click the box the widget belongs to in the sidebar list
- Click the widget from the box list
- Click the 'edit' button
- From the Layout Editor Content area
- Make appropriate changes to the widget properties.
- Click save at the top of the panel to save changes.
The widgets that are available can varying depending on the engines and plugins used within a particular installation of the CMS. Not all installations will necessarily have the same set of widgets. Their are however some core and extended widgets which are generally provided as part of every installation.
- Heading - Easy wrapper for consistent headings in a channel.
- Asset - Provides a simple way to add images/videos or file links to a layout.
- Gallery - Similar to assets but provides a way of consistently displaying grouped assets managed from the admin panel rather than the Layout Editor.
- Text - Allows for simple formatted text in a page.
- HTML - Adds the ability to display any HTML desired in a page.
- Navigation - Display related site map navigation elements in a consistent structure.
- Related Links - Displays other pages which are on the same subheading in the navigation tree.
- Horizontal Divider - Add a consistent divider between two widgets in a box.
- Information - Structured ways of displaying text/assets and links.
- Addthis - Provides simple integration with the http://www.addthis.com/ service.
- MetaTag - Allows for custom meta tags to be added to the layout (ex: open graph meta tags http://ogp.me/)
- Articles Widgets (various) - Adds in blogging and news functionality similar to other cms' with comment and tagging integration.
- Flash Message - Used to determine where messages from other widgets will be displayed in a layout.
- Feedback - Adds in ability for users to provide feedback managed through the admin panel.
- 360 Widget - Using assets from the asset library create an interactive rotating image.
Sometimes the existing widget set cannot be used to provide the functionality required for a particular page or layout. In this case a custom widget can be developed to satisfy the requirement and added to the available list of widgets as an engine.
Every widget in unroole has the following basic properties:
Widget Processing (Devs)
Since each layout can potentially contain many widgets each of which may rely on the data provided by other widgets in the layout a simple communication process exists to allow widgets to pass data between them. This could be useful, for example, when process a request on an e-commerce website where one widget manages items in a cart and then provides that information to other widgets on the page for use. This process uses a simple bundling mechanism called a Suitcase which captures some request data and can also be used to store data from other widgets. The widget communications process works as follows:
- prepare - Initially process the request data assuming no other data has been added to the suitcase by another widget. Data may be added to the suitcase during this step.
- create/update/delete - Depending on the request type create/update/delete data from the system or suitcase
- persist - Persist any processed data to permanent data stores.
- post - Finish any processing tasks that may have required a previous actions data
- persist - Persist any additional changes after the post
- respond - Information set in the previous actions is used to generate a response. Sometimes a widget can request a redirect or throw an error rather than simply render.
Since ordering of widget processing is not guaranteed all widgets are designed to be processed in any order.