Confinity Documentation
  • Latest Version
  • Latest Version
  • Getting Started

    • Introduction
    • Core Concepts
    • Create an Application
    • Glossary
  • Essentials

    • Authentication & SSO
    • Breaking Changes
    • Roslyn Source Analyzers
    • Changelog
    • ConfinityContent
    • ConfinitySelectable
    • Confinity Schedules
    • Data Seeding
    • Development guidelines [WIP]
    • Entity App
    • Entity Form
    • Entity Permissions
    • Frontend Configuration
    • Images
    • Known Issues
    • Localization
    • Migrations
    • Modules [WIP]
    • On-Site Editing
    • Settings
    • Cascade Delete
    • Replication
    • Infrastructure
  • Modules

    • Analytics Module
    • Assets Module
    • Blog Module
    • Cookie Consent Module
    • Forms Module
    • Friendly Captcha (Forms Module )
    • GeoIP Module
    • Htmx
    • Mail Module
    • Mailing Module
    • MediaPlayer Module
    • GoogleMyBusiness Module
    • OpenTelemetry Module
    • Pages Module [WIP]
    • Pattern Library Module
    • SIX Saferpay (worldline) Module
    • Products Module
    • Search Module
    • Wizard Module
  • Guides

    • Create a Custom Entity App Form Element
    • Date and Time
    • Entity Change Listener
    • File Upload / Temp File
    • HTTP security headers
    • conventions [WIP]
    • How to use Confinity with nginx
    • Notifications
    • Nullability
    • Rename Entity
    • Schedules
    • Useful snippets
    • Content Localization
  • Design Guidelines

    • Introduction
    • Page Components
    • Forms Module

Settings

With Confinity’s settigns app you can define configurations for your modules and apps that can be set by admins through a UI. The configuration data will be persisted to the database and you can obtain it through the options pattern. Since settings are based on ConfinityContent, you can create very flexible forms for your authors.

Register Settings

To define new settings you just create a new class which inherits from SettingsEntry.


public sealed class MyRocketSettings : SettingsEntry
{
    public int Height { get; set; }
    public EntityRef<Asset>? Image { get; set; }
}

In your module configuration you register your settings with an editor and optionally a description and an icon.


public void AddModule(IModuleContext module)
{
    module.Configure.RegisterSettings<MyRocketSettings>("Default Rocket Settings")
        .Key("default-rocket-key")
        .Editor(form =>
        {
            form.AddTab(tab =>
            {
                tab.AddInput(p => p.Height);
                tab.AddSelectAsset<MyRocketSettings>(p => p.Image);
            });
        });
}

Obtain Settings

You can obtain settings through DI by injecting ISettings<T>.


public class FoobarRocket
{
    private readonly MyRocketSettings _rocketSettings;

    public FoobarRocket(ISettings<MyRocketSettings> settings)
    {
        _rocketSettings = settings.CurrentValue;
    }

    public void StartRocket()
    {
        //do stuff with _rocketSettings
        int height = _rocketSettings.Height;
    }
}

Prev
On-Site Editing
Next
Cascade Delete