App
Settings in 2sxc
Settings allow your code to use predefined settings across all apps and sites. And they allow you to overide a setting at any level of the application. You can read more about the settings in the docs 📕.
Switch to Typed (2sxc 16+) Selected: Dynamic (Razor14 or below)
The following settings were configured on this View - see docs
⬇️ Result | Source ➡️
-
Settings.PrimaryColor
#8BC34AD9 -
Settings.SecondaryColor
#00BCD4B3 -
Settings.Tiles
(for example to configure images side-by-side):
The following settings were configured on this App - see docs
⬇️ Result | Source ➡️
-
App.Settings.PrimaryColor
#8BC34AD9 -
App.Settings.SecondaryColor
#00BCD4B3 -
App.Settings.QrForegroundColor
#000000 -
App.Settings.QrBackgroundColor
#FFFFFF -
App.Settings.QrDimension
200
Settings Stack
Global and local settings are merged together, so you can access them no matter where they were defined.
This demo app will be installed on many sites which don't have any settings, so there is no code to demo this.
⬇️ Result | Source ➡️
-
Settings.Images.Content.Width
1400 -
Settings.Images.Content.AspectRatio
1.618
Settings are stacked in a way that the View-settings have a higher priority than App-settings, which has a higher priority than Site, etc. In rare cases you may want to explicitly check for a setting at a specific place in the stack.
This example has a setting called CustomColor
which is set at App and View level. Using GetSource(...)
we can access a specific source.
⬇️ Result | Source ➡️
-
Settings.Get("CustomColor")
: #E91E63F2 -
View...Get("CustomColor")
: -
App...Get("CustomColor")
: #E91E63F2 -
Site...Get("CustomColor")
:
Note: this will be empty, as Site doesn't have this setting -
Global...Get("CustomColor")
:
Note: this will be empty, as Site doesn't have this setting