Develop widgets
What a widget is, what you need to write one and what to read next.
A widget is a building block of a CMS page, such as Headline, Picture or Link button. When the official widgets do not cover your need, you can write your own. A widget is one HTML file with some JavaScript and CSS, and you can create it in the CMS admin without other tools.
This section covers Total.js CMS 1.0. To use CMS itself, see the CMS guides.
How a widget works
| Word | What it means |
|---|---|
| Widget | The file: its server script, styles, settings form and the HTML that it adds to a page. CMS keeps one copy of each installed widget. |
| Instance | One use of the widget on a page. A page can hold the same widget many times, each with its own settings and content. |
| Configuration | The settings of one instance. The editor stores them in the page, next to the HTML of the instance. |
| Editor | The visual editor of CMS. It inserts the HTML of the widget, lets the user edit the parts that you mark, and opens your settings form. |
| Render | What happens on the public site. CMS builds the page from the saved HTML, and a widget can replace its part with content made on the server. |
A widget can be fully static: its HTML is all it needs. Add a server function only when the content must be made each time the page is built, such as data from another service.
What you need
- A running CMS and an account with the Widgets permission, or an administrator account.
- Basic HTML, CSS and JavaScript. The server script runs in Node.js with the Total.js 5 framework, so its helpers such as
RESTBuilderandTangularare available. - The editor and the public pages use the UI library of Total.js (jComponent), which the layout loads. Settings forms use its components, such as
input.
Safe use
The server script of a widget runs inside the CMS process with full access to the server. Give the Widgets permission only to people you trust, and install only widgets whose code you have read.
What to read next
- The widget file: the parts of the file.
- Your first widget: create it, add it to a page and change it.
- The topics in the menu: settings, editable content, rendering, styles and assets and install hooks.
- The reference: Widget file, Render, Settings script and Editor classes.