You can easily create your own Content Properties, you just need to implement IContentProperty for the content property and use IContentPropertySettings for the settings.
publicinterfaceIContentProperty{ // The freindly name shown in the CMS string Name { get; } // The alias used in the CMS and on the content typesstring Alias { get; } // Description explaining what your property doesstring Description { get;} // Icon that is shown in CMS (https://fonts.google.com/icons)string Icon { get; } // Optional: Your settings component if you publicType? SettingsComponent { get; set; } // The value that is savedstring? Value { get; set; } // Must be called to save any changes to Value and send back to content typeEventCallback<string> ValueChanged { get; set; } // Optional: The saved settings (Serialised)string? Settings { get; set; } // The content this property is onModels.Content? Content { get; set; } // Optional: Allows you to call a modal within the propertyIModalService? ModalService { get; set; } // Optional: Add any custom JS files your property needs hereList<string> Scripts { get; set; } // Optional: Add any custom CSS files your property needs hereList<string> Styles { get; set; }}
publicinterfaceIContentPropertySettings<T>{ // Must be called to send serialised settings back to content typeEventCallback<string> ValueChanged { get; set; } // Your settings (Serialised)publicstring? SettingsModel { get; set; } // The Type of your settingspublicT Settings { get; set; }}
Simple Custom Content Property
The code below is probably the simplest version of a property. It's just a text box, that someone can enter text in. We just make use of the ValueChanged event on the text box, to call our ValueChanged and store the text Value in our Value property.
@implements ZauberCMS.Core.Content.Interfaces.IContentProperty<RadzenTextBox Value="@Value" ValueChanged="@((string value) => ValueChanged.InvokeAsync(value))" ValueExpression="@(() => Value)" class="form-control"/>@code { [Parameter] public string? Value { get; set; } =string.Empty; [Parameter] public string? Settings { get; set; } =string.Empty; [Parameter] public Content? Content { get; set; } [Parameter] public EventCallback<string> ValueChanged { get; set; } [CascadingParameter] public IModalService? ModalService { get; set; } public List<string> Scripts { get; set; } = []; public List<string> Styles { get; set; } = []; public string Name { get; set; } ="Textbox"; public string Alias { get; set; } ="ZauberCMS.Textbox"; public string Icon { get; set; } ="border_color"; public string Description { get; set; } ="Standard text box"; public Type? SettingsComponent { get; set; }}