Skill for adding and configuring content fields in Orchard Core. Covers every built-in field type with all available settings, editor options, display modes, and migration code patterns.
You are an Orchard Core expert. Generate migration code and recipes for common content fields and verify feature-specific options against the enabled module.
AlterPartDefinitionAsync in a migration.FieldSettings base with Hint (string) and Required (bool).TextFieldSettings, NumericFieldSettings).ContentPartFieldSettings controlling DisplayName, Description, Editor, DisplayMode, and Position..WithEditor("EditorName") to select an editor variant..WithDisplayMode("DisplayModeName") to select a display variant.await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("{{FieldType}}")
.WithDisplayName("{{DisplayName}}")
.WithDescription("{{Description}}")
.WithPosition("{{Position}}")
.WithSettings(new {{FieldType}}Settings
{
// Field-specific settings
})
)
);
Stores a single text value. Supports multiple editor modes.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| DefaultValue | string | null | Default value for new content items. |
| Type | FieldBehaviorType | Unset | Field behavior type. |
| Pattern | string | null | The pattern used to build the value. |
| Placeholder | string | "" | Placeholder text. |
| Editor | Description |
|---|---|
| (default) | Standard single-line text input. |
| TextArea | Multi-line text area. |
| CodeMirror | Code editor with syntax highlighting. |
| PredefinedList | Dropdown or radio buttons from a predefined list. |
| Monaco | Monaco code editor. |
| Color | HTML color editor with an optional alpha value. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("TextField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new TextFieldSettings
{
Required = true,
Hint = "{{Hint}}",
DefaultValue = "{{DefaultValue}}",
Placeholder = "{{Placeholder}}"
})
)
);
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("TextField")
.WithDisplayName("{{DisplayName}}")
.WithEditor("TextArea")
.WithPosition("{{Position}}")
.WithSettings(new TextFieldSettings
{
Hint = "Enter a detailed description"
})
)
);
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("TextField")
.WithDisplayName("{{DisplayName}}")
.WithEditor("PredefinedList")
.WithPosition("{{Position}}")
.WithSettings(new TextFieldPredefinedListEditorSettings
{
Editor = EditorOption.Dropdown,
DefaultValue = "option1",
Options = new[]
{
new ListValueOption("Option 1", "option1"),
new ListValueOption("Option 2", "option2"),
new ListValueOption("Option 3", "option3")
}
})
)
);
Stores HTML content with optional sanitization.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| SanitizeHtml | bool | true | Whether to sanitize HTML content. |
| RenderLiquid | bool | false | Whether to evaluate Liquid before rendering the HTML. |
| Editor | Description |
|---|---|
| (default) | Rich text editor (WYSIWYG). |
| Wysiwyg | WYSIWYG HTML editor. |
| Trumbowyg | Trumbowyg WYSIWYG editor. |
| Monaco | Monaco code editor for raw HTML. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("HtmlField")
.WithDisplayName("{{DisplayName}}")
.WithEditor("Wysiwyg")
.WithPosition("{{Position}}")
.WithSettings(new HtmlFieldSettings
{
Required = true,
SanitizeHtml = true,
RenderLiquid = false,
Hint = "Enter HTML content"
})
)
);
Stores a numeric (decimal) value.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Scale | int | 0 | Number of decimal places. |
| Minimum | decimal? | null | Minimum allowed value. |
| Maximum | decimal? | null | Maximum allowed value. |
| Placeholder | string | null | Placeholder text. |
| DefaultValue | string | null | Default value. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("NumericField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new NumericFieldSettings
{
Required = true,
Minimum = 0,
Maximum = 999999,
Scale = 2,
Placeholder = "0.00",
Hint = "Enter the price"
})
)
);
Stores a true/false value.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Label | string | null | Label text for the checkbox. |
| DefaultValue | bool | false | Default checked state. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("BooleanField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new BooleanFieldSettings
{
Label = "Is Featured",
DefaultValue = false,
Hint = "Check to mark as featured"
})
)
);
Stores a date value (no time component).
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("DateField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new DateFieldSettings
{
Required = true,
Hint = "Select a date"
})
)
);
Stores a date and time value.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("DateTimeField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new DateTimeFieldSettings
{
Required = true,
Hint = "Select date and time"
})
)
);
Stores a time value.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Step | string | null | Step interval for the time picker (e.g., "00:15:00" for 15-minute steps). |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("TimeField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new TimeFieldSettings
{
Required = true,
Step = "00:15:00",
Hint = "Select a time"
})
)
);
References other content items.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Multiple | bool | false | Whether to allow selecting multiple content items. |
| DisplayAllContentTypes | bool | false | Whether to show all content types in the picker. |
| DisplayedContentTypes | string[] | [] | Content types to display in the picker. |
| DisplayedStereotypes | string[] | [] | Stereotypes to filter displayed content types. |
| Placeholder | string | "" | Placeholder text. |
| TitlePattern | string | "{{ Model.ContentItem \| display_text }}" | Liquid pattern for the displayed title. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("ContentPickerField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new ContentPickerFieldSettings
{
Required = true,
Multiple = false,
DisplayedContentTypes = new[] { "BlogPost", "Article" },
Hint = "Select a related article"
})
)
);
Attaches media files from the media library.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Multiple | bool | true | Whether to allow multiple files. |
| AllowMediaText | bool | true | Whether to allow alt text for media. |
| AllowAnchors | bool | false | Whether to allow anchor points on images. |
| AllowedExtensions | string[] | [] | Allowed file extensions (empty = all allowed). |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("MediaField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new MediaFieldSettings
{
Required = true,
Multiple = false,
AllowMediaText = true,
AllowedExtensions = new[] { ".jpg", ".jpeg", ".png", ".gif", ".webp" },
Hint = "Upload an image"
})
)
);
Stores a URL with optional link text and target.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| HintLinkText | string | null | Hint text for the link text input. |
| LinkTextMode | LinkTextMode | Optional | Link text mode (Optional, Required, Static, Url). |
| UrlPlaceholder | string | null | Placeholder for the URL input. |
| TextPlaceholder | string | null | Placeholder for the text input. |
| DefaultUrl | string | null | Default URL value. |
| DefaultText | string | null | Default link text. |
| DefaultTarget | string | null | Default target (e.g., _blank). |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("LinkField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new LinkFieldSettings
{
Required = true,
LinkTextMode = LinkTextMode.Required,
UrlPlaceholder = "https://example.com",
TextPlaceholder = "Click here",
Hint = "Enter an external link"
})
)
);
Stores multiple text values from predefined options.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Options | MultiTextFieldValueOption[] | [] | Available options with Name, Value, and Default. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("MultiTextField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new MultiTextFieldSettings
{
Options = new[]
{
new MultiTextFieldValueOption { Name = "Red", Value = "red", Default = false },
new MultiTextFieldValueOption { Name = "Green", Value = "green", Default = true },
new MultiTextFieldValueOption { Name = "Blue", Value = "blue", Default = false }
},
Hint = "Select one or more colors"
})
)
);
References users.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Multiple | bool | false | Whether to allow multiple users. |
| DisplayAllUsers | bool | true | Whether to display all users. |
| DisplayedRoles | string[] | [] | Roles to filter displayed users. |
| Placeholder | string | "" | Placeholder text. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("UserPickerField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new UserPickerFieldSettings
{
Required = true,
Multiple = false,
DisplayAllUsers = false,
DisplayedRoles = new[] { "Author", "Editor" },
Hint = "Select an author"
})
)
);
Stores a YouTube video URL and embeds the player.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| Label | string | null | Label text. |
| Width | int | 0 | Embed player width (0 = default). |
| Height | int | 0 | Embed player height (0 = default). |
| Placeholder | string | "" | Placeholder text. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("YoutubeField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new YoutubeFieldSettings
{
Required = false,
Width = 640,
Height = 360,
Placeholder = "https://www.youtube.com/watch?v=...",
Hint = "Paste a YouTube video URL"
})
)
);
References taxonomy terms. Provided by the OrchardCore.Taxonomies module.
| Setting | Type | Default | Description |
|---|---|---|---|
| Hint | string | null | Help text displayed below the field. |
| Required | bool | false | Whether the field is required. |
| TaxonomyContentItemId | string | null | The content item ID of the taxonomy. |
| Unique | bool | false | Whether to enforce unique selection. |
| LeavesOnly | bool | false | Whether to allow only leaf terms (no parents). |
| Open | bool | false | Whether the taxonomy tree is open by default. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("TaxonomyField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
.WithSettings(new TaxonomyFieldSettings
{
Required = true,
TaxonomyContentItemId = "{{TaxonomyContentItemId}}",
LeavesOnly = true,
Hint = "Select a category"
})
)
);
References content items by localization set (for multi-lingual content). Provided by OrchardCore.ContentLocalization.
| Setting | Type | Default | Description |
|---|---|---|---|
| Multiple | bool | false | Whether to allow more than one localization set. |
| DisplayedContentTypes | string[] | [] | Content types offered by the picker. |
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("LocalizationSetContentPickerField")
.WithDisplayName("{{DisplayName}}")
.WithPosition("{{Position}}")
)
);
Stores Markdown on a part field. Enable OrchardCore.Markdown.
| Setting | Type | Default | Description |
|---|---|---|---|
| SanitizeHtml | bool | true | Sanitizes rendered HTML. |
| RenderLiquid | bool | false | Evaluates Liquid before rendering Markdown. |
SanitizeHtml and RenderLiquid are independent. Sanitization can remain
enabled while Liquid rendering is disabled, or Liquid can be evaluated before
the rendered output is sanitized.
Use the default editor or .WithEditor("Wysiwyg"); the WYSIWYG editor accepts MarkdownFieldWysiwygEditorSettings.Options.
await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
.WithField("{{FieldName}}", field => field
.OfType("MarkdownField")
.WithEditor("Wysiwyg")
.WithSettings(new MarkdownFieldSettings
{
SanitizeHtml = true,
RenderLiquid = false,
})
)
);
Stores latitude and longitude. Enable OrchardCore.Spatial; its field settings are the common Hint and Required settings. Use .WithEditor("Leaflet") for the built-in map editor.
For related content-part and route configuration, see orchardcore-content-parts and orchardcore-autoroute.
Modules that provide custom fields from external sources (community or third-party modules) must be installed as NuGet packages in the web project (the startup project of the solution):
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<!-- Orchard Core base -->
<PackageReference Include="OrchardCore.Application.Cms.Targets" Version="3.*" />
<!-- Third-party modules must be added to the web project -->
<PackageReference Include="Lombiq.HelpfulExtensions.OrchardCore" Version="1.*" />
</ItemGroup>
</Project>
For local project references to third-party modules:
<ItemGroup>
<!-- Local third-party module project reference in the web project -->
<ProjectReference Include="../ThirdParty.Module/ThirdParty.Module.csproj" />
</ItemGroup>
npx skills add CrestApps/orchardcore-content-fields下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer