Content model properties show up in the Redakt back-office user interface as input fields for content managers. Every property has an associated property editor, which determines how the property input looks and behaves in the back office. The property editors are responsible for reading and writing values to content items.
Configuration
For many properties, you will not have to do any configuration at all. By convention, Redakt selects the property editor that is most suitable for the property type. For example, a string type will result in a single line text property editor.
However, if you wish to change the behavior of a property editor or use a different property editor altogether, you can do so by decorating the property with the appropriate attributes. For example, for a string property type, you could configure a multiline text input, or use a rich text editor instead. See the lists below for more details on the standard property editors and attributes, and how to configure them. The example below shows a few different property configurations.
public class SomeContent: IContentType
{
// Default single line text input.
public string Title { get; set; }
// Required multiline plain text input (textarea) with max length of 200 characters.
[Required]
[Multiline]
[MaxLength(200)]
public string Intro { get; set; }
// Selects rich text editor, also default editor for HtmlString.
[RichTextEditor]
public string Body { get; set; }
// Number editor; value not required.
public int? Count { get; set; }
// Number editor with 2 decimals and min/max value; value is required because the type is not nullable.
[NumberEditor(Decimals = 2, Minimum = 0, Maximum = 10000)]
public decimal Price { get; set; }
// Select list with constant options and placeholder text.
[SelectList("black:Black Tea", "green:Green Tea", "rooibos:Rooibos", "chai:Chai")]
[Placeholder("Select some tea")]
public string FavouriteTea { get; set; }
}
Standard Property Editors
Redakt CMS comes with a large number of built-in property editors that should meet the needs of most websites. See the individual guides for editor features and how to configure them.
- TextboxEditor is a single or multi-line plain text input.
- RichTextEditor is a HTML rich text editor.
- NumericEditor is an input for numeric values.
- CheckboxEditor displays a checkbox.
- DateTimeEditor is a calendar-style editor for date, date/time or time values.
- SelectEditor is a dropdown, radio, or select list for single and multiple values.
- TagsEditor is an editor for selecting or adding tags.
- FileEditor is a file and media upload control.
- NestedContentEditor is a repeater control for nested content items and library assets.
- LinkEditor is a page browser for selecting links and URLs.
- NodePicker is a browser to select internal page nodes.
- TableEditor is an editor for managing tabular data.
Property Editor Attributes
This is a list of all attributes that can be used to change property editor behavior and validation. The property editor guides discuss these attributes, but they are listed here as well for convenience. Most attributes can only be applied to a limited number of property editors. Some attributes are specific to a single property editor.
These attributes only apply when editing content with the back office application (user-interactive input). Specifically, validation attributes do not have any effect when changing content through back-end code.
Behavior attributes
These attributes change the behavior and display of the editor in the back office.
- Checkbox attribute renders a checkbox editor for this property.
- DateTimeEditor attribute renders a date/time editor for this property.
- Editor attribute sets or overrides the editor type used for a property.
- Expanded attribute specifies that nested content should start expanded.
- LinkEditor attribute configures a link browser editor.
- Multiline attribute renders a multiline textbox.
- NumberEditor attribute renders a numeric value editor for this property.
- Placeholder attribute sets a placeholder for supporting editors.
- Prefix attribute sets a prefix to display next to the editor.
- RadioGroup attribute renders a radio group editor for this property.
- RichTextEditor attribute renders a rich text editor for this property.
- SelectList attribute renders a dropdown, radio, or select list for this property.
- StartFolder attribute sets the start folder for content pickers.
- TagsEditor attribute renders a tags editor for this property.
- Width attribute sets the field width of the editor in the user interface.
Validation attributes
These attributes set validation rules against which property value input is validated.
- MaxCount attribute sets the maximum number of content values allowed for collection property types.
- MaxLength attribute (*) sets the maximum length allowed for string properties.
- MinCount attribute sets the minimum number of content values required for collection property types.
- MinLength attribute (*) sets the minimum length required for string properties.
- Range attribute (*) sets the range (min/max) that values for this property must be inside.
- RegularExpression attribute (*) specifies a regular expression to validate against.
- Required attribute (*) specifies that the value is required.
(*) These are not Redakt attributes but standard .NET attributes from the System.ComponentModel.DataAnnotations
namespace. All other attributes are part of the Redakt.ContentManagement.Annotations
namespace.
Custom Property Editors
If you need a different property editor from any of the standard ones, you can create your own property editor. This involves creating a user interface for the editor in Blazor, and a small .NET class for editor definitions and settings.
You can find an example of a custom property editor (OpenStreetMap location picker) as part of the Redakt Hotel & Resort Demo project on GitHub.