Get the FREE Ultimate OpenClaw Setup Guide →

orchardcore-content-types

Scanned
npx machina-cli add skill CrestApps/CrestApps.AgentSkills/orchardcore-content-types --openclaw
Files (1)
SKILL.md
2.7 KB

Orchard Core Content Types - Prompt Templates

Create a Content Type

You are an Orchard Core expert. Generate code and configuration for creating a content type.

Guidelines

  • Content type technical names must be PascalCase with no spaces.
  • Always include a TitlePart unless the content type uses a custom title strategy.
  • Add AutoroutePart for routable content types with a URL pattern.
  • Use CommonPart conventions (owner, created/modified dates) where appropriate.
  • Attach ListPart if the content type should act as a container.
  • Use content part and field settings to configure editors and display modes.

Migration Pattern

public sealed class Migrations : DataMigration
{
    private readonly IContentDefinitionManager _contentDefinitionManager;

    public Migrations(IContentDefinitionManager contentDefinitionManager)
    {
        _contentDefinitionManager = contentDefinitionManager;
    }

    public async Task<int> CreateAsync()
    {
        await _contentDefinitionManager.AlterTypeDefinitionAsync("{{ContentTypeName}}", type => type
            .DisplayedAs("{{DisplayName}}")
            .Creatable()
            .Listable()
            .Draftable()
            .Versionable()
            .WithPart("TitlePart", part => part
                .WithPosition("0")
            )
            .WithPart("AutoroutePart", part => part
                .WithPosition("1")
                .WithSettings(new AutoroutePartSettings
                {
                    AllowCustomPath = true,
                    Pattern = "{{ ContentItem | display_text | slugify }}"
                })
            )
        );

        return 1;
    }
}

Content Field Configuration

When adding fields to a content part:

await _contentDefinitionManager.AlterPartDefinitionAsync("{{PartName}}", part => part
    .WithField("{{FieldName}}", field => field
        .OfType("{{FieldType}}")
        .WithDisplayName("{{FieldDisplayName}}")
        .WithPosition("{{Position}}")
    )
);

Common field types include:

  • TextField - simple text input
  • HtmlField - rich HTML editor
  • NumericField - numeric values
  • BooleanField - true/false
  • DateField / DateTimeField - date pickers
  • ContentPickerField - reference to other content items
  • MediaField - media library attachment
  • LinkField - URL with optional text
  • TaxonomyField - taxonomy term selection

Source

git clone https://github.com/CrestApps/CrestApps.AgentSkills/blob/main/src/CrestApps.AgentSkills/orchardcore/orchardcore-content-types/SKILL.mdView on GitHub

Overview

This skill enables creating, managing, and configuring Orchard Core content types. It covers content part definitions, content field definitions, stereotypes, and content type indexing, with migration patterns and editor configurations.

How This Skill Works

Content types are defined and updated using the IContentDefinitionManager within a migration. You create a type by name (PascalCase), assign a DisplayName, and attach parts such as TitlePart, AutoroutePart, and ListPart, then fine-tune fields on parts via AlterPartDefinitionAsync.

When to Use It

  • When creating a new content type for a feature or module
  • When making a content type routable by adding an AutoroutePart with a URL pattern
  • When turning a content type into a container using ListPart
  • When configuring editors and display via Field types (TextField, HtmlField, etc.)
  • When applying standard CommonPart conventions (owner, created/modified dates) and part-based composition

Quick Start

  1. Step 1: Create a Migrations class and inject IContentDefinitionManager
  2. Step 2: In CreateAsync(), call AlterTypeDefinitionAsync to define the type and attach parts
  3. Step 3: Use AlterPartDefinitionAsync to add and configure fields (e.g., TextField, HtmlField) on parts

Best Practices

  • Use PascalCase for content type technical names with no spaces
  • Always include TitlePart unless using a custom title strategy
  • Attach AutoroutePart for routable types with a Pattern
  • Leverage CommonPart conventions where appropriate (owner, created/modified dates)
  • Test migrations in a dev environment and preview content rendering

Example Use Cases

  • BlogPost content type with TitlePart, AutoroutePart, and HtmlField for content
  • Product content type with fields like Price (NumericField) and Description (HtmlField)
  • Recipe content type with ContentPickerField for ingredients and HtmlField for steps
  • Event content type with DateTimeField for date and Location fields
  • GalleryItem content type with MediaField for images and TitlePart

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers