Content fields
Content fields are pieces of information that can be added to a content type. Content fields have a name and a type and are specific to a content type.
For example, a Product content type can have a text field representing its Sku, a numeric field representing its price, and another numeric field representing its weight. Each of these fields probably only makes sense on a product.
Adding a field to a content type is as simple as defining a public property with a getter and setter. You should also annotate it with the PersistedAttribute
as in the following example.
public class Product : Content {
[Persisted]
public string Sku { get; set; }
}
Controlling the user interface
Lemoon automatically generates an administrative user interface for displaying and editing content items. You can control how the individual properties of a content type will be displayed end edited by adding additional attributes to the fields of your content type.
Lemoon has a number of built in controls (it is also possible to create your own UI control) that are capable of rendering fields of a specific data-type and style. These range from a simple textbox for a single-line string to controls capable of selecting multiple content items. The actual data type of the property (e.g. string
, int
, bool
), the DataTypeAttribute
and the UIHintAttribute
determines how Lemoon renders the field.
[Persisted]
public string StringField { get; set; }
Single line textbox.
[Persisted]
[DataType(DataType.MultilineText)]
public string TextAreaField { get; set; }
Multi line textbox.
[Persisted]
[DataType(DataType.Html)]
public string HtmlField { get; set; }
Rich text editor for HTML.
[Persisted]
[DataType("Source")]
public string SourceField { get; set; }
Code editor.
[Persisted]
[DataType(DataType.Email)]
public string EmailField { get; set; }
Textbox with validator for email address.
[Persisted]
[DataType(DataType.Url)]
public string UrlField { get; set; }
Textbox with validator for url.
[Persisted]
[DataType(DataType.Password)]
public string PasswordField { get; set; }
Textbox with masked input for passwords.
[Persisted]
[DataType("Hidden")]
public string HiddenField { get; set; }
Hidden field.
[Persisted]
public bool BooleanField { get; set; }
Checkbox.
[Persisted]
[DataType(DataType.DateTime)]
public DateTime? DateTimeField { get; set; }
Date and time picker.
[Persisted]
[DataType(DataType.Date)]
public DateTime? DateField { get; set; }
Date picker.
[Persisted]
[DataType(DataType.Time)]
public DateTime? TimeField { get; set; }
Time picker.
[Persisted]
public int? IntegerField { get; set; }
Textbox with validator for integers.
[Persisted]
public double? DoubleField { get; set; }
Textbox with validator for decimal values.
[Persisted]
[DataType("Select")]
[UIHint(null, null, "Item 1", "1", "Item 2", "2", "Item 3", "3")]
public string SelectField { get; set; }
Dropdown list.
[Persisted]
[DataType("SelectMany")]
[UIHint(null, null, "Item 1", "1", "Item 2", "2", "Item 3", "3")]
public List<string> SelectManyField { get; set; }
Select list.
[Persisted]
[DataType("CheckBoxList")]
[UIHint(null, null, "Item 1", "1", "Item 2", "2", "Item 3", "3")]
public List<bool> CheckBoxesField { get; set; }
Checkbox list.
[Persisted]
[DataType("Radio")]
[UIHint(null, null, "Item 1", "1", "Item 2", "2", "Item 3", "3")]
public string RadioButtonsField { get; set; }
Radio button list.
[Persisted]
[DataType("~/lemoon/usercontrols/myusercontrol.ascx")]
public string UserControlField { get; set; }
Custom user control.
[Persisted]
[DataType("MyProject.Lemoon.WebControls.MyWebControl")]
public string WebControlField { get; set; }
Custom web server control.
[Persisted]
[DataType("Content")]
public ContentRef ContentPicker { get; set; }
Content picker.
[Persisted]
[DataType("Contents")]
public List<ContentRef> MultipleContentPicker { get; set; }
Multiple content picker
[Persisted]
[DataType("File")]
public ContentRef FilePicker { get; set; }
File picker
[Persisted]
[DataType("Files")]
public List<ContentRef> MultipleFilePicker { get; set; }
Multiple file picker
[Persisted]
[DataType("Folder")]
public ContentRef FolderPicker { get; set; }
Folder picker
[Persisted]
[DataType("Folders")]
public List<ContentRef> MultipleFolderPicker { get; set; }
Multiple folder picker
[Persisted]
[DataType("Page")]
public ContentRef PagePicker { get; set; }
Page picker
[Persisted]
[DataType("Pages")]
public List<ContentRef> MultiplePagesPicker { get; set; }
Multiple page picker.
[Persisted]
[DataType("User")]
public UserRef UserPicker { get; set; }
User picker.
[Persisted]
[DataType("Users")]
public List<UserRef> MultipleUserPicker { get; set; }
Multiple user picker.
[Persisted]
[DataType("Role")]
public RoleRef RolePicker { get; set; }
Role picker.
[Persisted]
[DataType("Roles")]
public List<RoleRef> MultipleRolePicker { get; set; }
Multiple role picker.