1.5. Themes

MWT supports the creation of multiple themes. Each theme can define CSS styles, structure and configuration of pages (the page internal list of widgets and their configuration) and can contain a set of new widgets.

All themes inherit from the default theme and can extend and/or overwrite its characteristics. When writing a theme you normally start from an empty one. Thanks to inheritance an empty theme is basically just a copy of the default one, so you just have to define the differences.

Themes can be configured in MWT Themes editor. This is where you also set the current theme to be used for rendering pages.

In its template.css file a theme can provide the CSS style sheet to be included in pages. When writing the template file it is possible to use the values of a set of parameters that can be configured in MWT Themes editor. Parameters are referenced in the template by means of an expression language that is part of the taglib engine (described in chapter 2). In the process of page generation, the expression language from the template file is expanded to generate the final style sheet. To know more about how to script your CSS template read paragraph Scripting the CSS template with the expression language. While the expression language and how to reference style parameters in the template will be described in the next chapter, in this paragraph it is explained how to define parameters.

Let's go back to the syntax of the theme.xml file shown in the previous paragraph, focusing this time on the content of the css tag. This is where style parameters can be defined. Each parameter must have a name, while type will default to text, values and the parameter value will default to an empty string. Type value will determine the form element that will be used to set a value for the parameter in the editor. It can be one of the following:

  • text (default): a plain text input field
  • color: color picker
  • *select: select (combobox).

*Only for the select type it makes sense to specify a comma-separated list of values.

A theme can contain a new set of widgets (widgets files must be placed in a directory called widgets inside the main directory of the theme) or use widgets from the default theme.

When a page renders itself, it consecutively evaluates the code of its inner widgets. Before rendering a widget, the system first checks the existance of the widget file in the widgets directory of the current theme and if the widget is not found then it searched in the widgets directory of the default theme.