Theme as data
(Updated Edited template to July 12, 2025.)
No edit summary
 
Line 6: Line 6:
The pattern for Turnkey to discover for applying data as CSS is this:  
The pattern for Turnkey to discover for applying data as CSS is this:  
  SysSingleton.oclsingleton.PickedThemeData , and the object found must ha Name:string and DerivedCSS:string
  SysSingleton.oclsingleton.PickedThemeData , and the object found must ha Name:string and DerivedCSS:string
An example model to add both this model section plus a UI to set CSS theming variables is found here: [[Model Examples|Theme Builder]]
An example model to add both this model section plus a UI to set CSS theming variables is found here: [[Documentation:Model Examples|Theme Builder]]


=== Basic Example ===
=== Basic Example ===

Latest revision as of 05:11, 3 February 2025

This page was created by Hans.karlsen@mdriven.net on 2020-06-24. Last edited by Stephanie@mdriven.net on 2025-02-03.

MDriven Turnkey has now added support to keep your theme and CSS as data within your app.

Having the CSS rules as data within the app rather than as a file on the server opens up other possibilities to react to other data. It makes it possible to change between multiple sets of CSS rules (themes) in runtime.

The pattern for Turnkey to discover for applying data as CSS is this:

SysSingleton.oclsingleton.PickedThemeData , and the object found must ha Name:string and DerivedCSS:string

An example model to add both this model section plus a UI to set CSS theming variables is found here: Theme Builder

Basic Example

This example sets the background of the navigation bar.

ThemeDataWithLink.PNG

DerivationOcl.PNG

Good to know

  • The corresponding rule in tkusercss.css file will override your value if set.
  • You will probably have to touch your web.config, restart your Turnkey site and reload your page when testing.

To identify what theme variables will have effect in Turnkey - check names used in StylesInModel dialog:

Documentation Theme as data 1723709327369.png

See SysSingleton.MiscSetting to see how to trigger a generation of the CSS in runtime.


MDriven Chat

How would you like to chat today?

Setting up your conversation…

This may take a few moments