This section contain advanced theme configuration:
Writing theme XML
As well as using the normal Theme type (library.theme.ThemeType) to define themes, you can define themes in XML using the system Theme type (system.THEME_TYPE). The syntax of the XML is as described in Theme XML reference. The system theme type can also be useful if you want to generate themes.
Even if you do use the normal Theme type (library.theme.ThemeType), you can create XML-based statements by using the general-purpose Data Node type (system.DATA_NODE_TYPE), and including these as resources. You can use this to define one or more resources, to define theme properties, or even include statements. This can be particularly useful in a small number of scenarios:
- When you want to include other themes by node reference without a version number.
- When you want to apply filters before outputting content (see Content filters below).
Working with the default theme
All themes include the underlying Default Theme (system.app.DefaultTheme), either directly or indirectly. This contains all the styling and components required for Metrici to function.
If you are writing significant themes, look at the resources in the default theme. You may be able to fulfil dependencies that your components have by requiring resources that are already in the default theme, removing the need to include other resources and avoiding clashes. If you need to tweak specific things (such as, say, the bootstrap theming for data tables), examining the default theme will help identify what you need to change, which you can either do by adding additional CSS to override the default styling, or, if the changes are extensive, providing your own resource statement which will replace the one in the default theme.
Changing the Bootstrap theme
Rather than just override some aspects of the style, many themes want to change the underlying Bootstrap theme.
You can use tools like BootSwatchr to create a new Bootstrap theme. Once you have downloaded your new Bootstrap theme, including it in a Metrici theme is easy:
- Create a resource with reference bootstrap-css.
- Put it in section css-framework.
- In the content, use <link> statements to bring in your version of bootstrap.min.css.
You should only override Bootstrap CSS, as Metrici functionality depends on the Bootstrap JavaScript as defined in the default theme.
If you just want to override parts of the bootstrap theme:
- Create a resource with a suitable reference.
- Put it in section css-framework.
- Set it to follow bootstrap-css.
You will also need to reference your resource on a depends on the head or custom resource.
Content filters
By default, the content for a resource is brought in whenever that resource, or a resource on which it depends, is present in the page.
You can add filters to fine-tune when the content should be included. The filters don't alter the resource dependency calculations, but can be used to effectively switch off the content. See Theme XML reference for a description of the syntax.