Orchardcore templates

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore templates is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for customizing templates in Orchard Core via the admin UI. Covers shape template overrides, content type templates, content part templates, content field templates, differentiated display types, Liquid template syntax, admin template editing, the Templates and AdminTemplates recipe steps, tem

How to use this skill

Skill file

Orchard Core Templates - Prompt Templates

Customizing Templates in Orchard Core

You are an Orchard Core expert. Generate template overrides and explain template naming conventions for Orchard Core shapes.

Guidelines

Features, Permissions, and Liquid Security

| Feature | Admin menu | Permission |

|---|---|---|

| OrchardCore.Templates (depends on OrchardCore.Liquid) | Design > Templates | ManageTemplates (Administrator, Editor) |

| OrchardCore.AdminTemplates | Design > Admin Templates | ManageAdminTemplates (Administrator) |

| OrchardCore.Templates.Assisted (depends on OrchardCore.Templates) | Theme Templates and Feature Templates buttons on both pages | Same as the page |

| OrchardCore.Templates.ShapeTracing (depends on Assisted Templates, OrchardCore.Contents, OrchardCore.ContentFields) | Inspect Content button, content type alternates, Inspect templates content item action | Same as the page, plus ViewContent on the inspected item |

Every template action, including previews, also requires the security-critical

OrchardCore.Liquid.Permissions.ManageLiquidTemplates permission (granted to

Administrator and Editor by default). Without it the template menus and the

Templates shortcuts on the content type, part, and type-part editors are

hidden. Grant it explicitly to custom roles that manage templates.

.liquid shape templates, from the admin or from theme files, are rendered by

LiquidShapeTemplateViewEngine directly with Fluid; Razor no longer renders

them as LiquidPage partials. Behavior and PO localization contexts are

unchanged.

The template editor's Preview tab renders the template with ~/OrchardCore.Templates/Scripts/template-editors/template-preview.min.js (a 4.0 regression where the script never loaded and the tab stayed blank is fixed). An override of Views/Preview/Index.cshtml must register its at="Foot" scripts before <resources type="Footer" />, or they are never written.

Templates Recipe Steps

Templates are keyed by shape name; Content is the Liquid source:

{
  "steps": [
    {
      "name": "Templates",
      "Templates": {
        "Content__BlogPost": {
          "Description": "Blog post detail",
          "Content": "<article><h1>{{ Model.ContentItem.DisplayText }}</h1>{{ Model.Content | shape_render }}</article>"
        }
      }
    },
    {
      "name": "AdminTemplates",
      "AdminTemplates": {
        "Content_SummaryAdmin__Article": {
          "Description": "Article admin list row",
          "Content": "{{ Model.Header | shape_render }}{{ Model.Content | shape_render }}"
        }
      }
    }
  ]
}

The All Templates (AllTemplates) and All Admin Templates

(AllAdminTemplates) deployment steps export these steps. With

ExportAsFiles, each template is written to Templates/{Name}.liquid or

AdminTemplates/{Name}.liquid (__ becomes -, _ becomes .) and

referenced as

"Content": "[file:text('Templates/Content-BlogPost.liquid')]".

Content Type Templates

`Content__[ContentType]`

Renders a content item when displayed at its own URL (Detail display type).

| Template Name | Filename |

|---------------------|---------------------------|

| Content__BlogPost | Content-BlogPost.cshtml |

| Content__Article | Content-Article.cshtml |

Available properties:

| Property | Description |

|-----------------------------|----------------------------------------------------------------|

| Model.Content | Zone shape containing all shapes from parts and fields |

| Model.ContentItem | The current content item being rendered |

| Model.ContentItem.Content | JSON object with all content item data |

`Content_[DisplayType]__[ContentType]`

Renders a content item with a specific display type (e.g., Summary in lists).

| Template Name | Filename |

|-----------------------------|-----------------------------------|

| Content_Summary__BlogPost | Content-BlogPost.Summary.cshtml |

| Content_Summary__Article | Content-Article.Summary.cshtml |

`Content__Alias__[Alias]`

Renders a content item by its alias (requires AliasPart).

| Template Name | Filename |

|----------------------------|--------------------------------|

| Content__Alias__example | Content-Alias-example.cshtml |

`Content__Slug__[Slug]`

Renders a content item by its slug (requires AutoroutePart). Path separators / become __ in template names and - in filenames.

| Template Name | Filename |

|---------------------------------|------------------------------------|

| Content__Slug__example | Content-Slug-example.cshtml |

| Content__Slug__blog__my__post | Content-Slug-blog-my-post.cshtml |

Widget Templates

`Widget__[ContentType]`

Renders a widget on a page.

| Template Name | Filename |

|----------------------|----------------------------|

| Widget__Paragraph | Widget-Paragraph.cshtml |

| Widget__Blockquote | Widget-Blockquote.cshtml |

Available properties:

| Property | Description |

|-----------------------------|----------------------------------------------------------|

| Model.Content | Zone shape with all shapes from the widget's parts/fields |

| Model.ContentItem | The widget content item |

| Model.ContentItem.Content | JSON object with widget data |

| Model.Classes | Array of CSS classes attached to the widget |

Content Part Templates

`[ShapeType]`

Default template for a content part shape. The shape type usually matches the part name.

| Template Name | Filename |

|----------------|-----------------------|

| HtmlBodyPart | HtmlBodyPart.cshtml |

`[ShapeType]_[DisplayType]`

Part shape with a specific display type.

| Template Name | Filename |

|------------------------|-------------------------------|

| HtmlBodyPart_Summary | HtmlBodyPart.Summary.cshtml |

`[ContentType]__[PartType]`

Part shape scoped to a specific content type.

| Template Name | Filename |

|--------------------------|------------------------------|

| Blog__HtmlBodyPart | Blog-HtmlBodyPart.cshtml |

| LandingPage__BagPart | LandingPage-BagPart.cshtml |

`[ContentType]_[DisplayType]__[PartType]`

Part shape scoped to content type and display type.

| Template Name | Filename |

|-----------------------------------|--------------------------------------|

| Blog_Summary__HtmlBodyPart | Blog-HtmlBodyPart.Summary.cshtml |

`[ContentType]__[PartName]`

Named part scoped to a content type (for reusable named parts like BagPart).

| Template Name | Filename |

|-------------------------|-------------------------------|

| LandingPage__Services | LandingPage-Services.cshtml |

Custom Model Shape Templates

Display drivers for non-content-item models follow the same shape naming rules, but they often need both a root wrapper template and child-zone templates.

Example shape names and filenames:

| Shape Name | Filename |

|---|---|

| CampaignAction_Edit | CampaignAction.Edit.cshtml |

| CampaignAction_SummaryAdmin | CampaignAction.SummaryAdmin.cshtml |

| CampaignActionFields_Edit | CampaignActionFields.Edit.cshtml |

| CampaignAction_Fields_SummaryAdmin | CampaignAction.Fields.SummaryAdmin.cshtml |

| CampaignAction_Buttons_SummaryAdmin | CampaignAction.Buttons.SummaryAdmin.cshtml |

When a driver uses placement such as .Location("SummaryAdmin", "Content:1") and .Location("SummaryAdmin", "Actions:5"), CampaignAction.SummaryAdmin.cshtml must render Model.Content and Model.Actions for those child shapes to appear.

Content Field Templates

`[ShapeType]_[DisplayType]`

Field shape with a display type.

| Template Name | Filename |

|---------------------|----------------------------|

| TextField_Summary | TextField.Summary.cshtml |

`[PartType]__[FieldName]`

Field scoped to a part type.

| Template Name | Filename |

|------------------------------|-----------------------------------|

| HtmlBodyPart__Description | HtmlBodyPart-Description.cshtml |

`[ContentType]__[PartName]__[FieldName]`

Field scoped to content type and part name.

| Template Name | Filename |

|-----------------------------------|-------------------------------------------|

| Blog__HtmlBodyPart__Description | Blog-HtmlBodyPart-Description.cshtml |

| LandingPage__Services__Image | LandingPage-Services-Image.cshtml |

Widget / Stereotype Part Templates

Parts attached to stereotyped content types (e.g., Widget) get additional alternates:

| Template Name | Filename |

|-----------------------------|----------------------------------|

| Widget__HtmlBodyPart | Widget-HtmlBodyPart.cshtml |

Zone Templates

`Zone__[ZoneName]`

Renders a layout zone.

| Template Name | Filename |

|-----------------|-----------------------|

| Zone__Footer | Zone-Footer.cshtml |

| Zone__Content | Zone-Content.cshtml |

Available properties:

| Property | Description |

|------------------|-----------------------------------------------|

| Model.Items | Child shapes to render from the zone |

| Model.Parent | Parent zone shape (Layout for root zones) |

| Model.ZoneName | Name of the zone (e.g., "Footer", "Content") |

Rendering Zone Children

Liquid:

{% for shape in Model.Items %}
    {{ shape | shape_render }}
{% endfor %}

Razor:

@foreach (var shape in Model)
{
    @await DisplayAsync(shape);
}

Shape Differentiators

Differentiators uniquely identify a shape in a zone for placement and template access:

Accessing Shapes by Differentiator

Razor:

// Access by name
Model.Content.HtmlBodyPart;
Model.Content.Named("ListPart-ListPartFeed");

// Remove a shape
Model.Content.Remove("HtmlBodyPart");

Liquid:

{%- comment -%} Display a specific shape {%- endcomment -%}
{{ Model.Content.HtmlBodyPart | shape_render }}

{%- comment -%} Remove then render remaining {%- endcomment -%}
{% shape_remove_item Model.Content "HtmlBodyPart" %}
{{ Model.Content | shape_render }}

{%- comment -%} Access field shape for a field added directly to content type {%- endcomment -%}
{{ Model.Content["Article-Description"] | shape_render }}

{%- comment -%} Access field property directly {%- endcomment -%}
{{ Model.Content["Article-Description"].Field.Text }}

Content Part Display Modes

Parts that support display modes get additional alternates:

| Template Name | Filename |

|------------------------------------------------------|-----------------------------------------------------------|

| TitlePart_Summary__CustomMode_Display | TitlePart-CustomMode.Display.Summary.cshtml |

| LandingPage_Display__TitlePart__CustomMode | LandingPage-TitlePart-CustomMode.Display.cshtml |

| LandingPage_Summary__TitlePart__CustomMode_Display | LandingPage-TitlePart-CustomMode.Display.Summary.cshtml |

Template Precedence

Templates are resolved in this order (highest to lowest priority):

  1. Admin-defined templates (via Templates module)
  2. Active theme templates
  3. Module-provided templates

Within theme/module templates, more specific alternates take priority over generic ones.

Overriding Module Views

Some module views (not shapes) can be overridden in your theme by placing them at:

YourTheme/Views/[ModuleName]/[Controller]/[Action].cshtml

Example: Override the login page:

YourTheme/Views/OrchardCore.Users/Account/Login.cshtml

Example: Custom Blog Post Detail Template

Admin template name: Content__BlogPost

<article>
    <h1>{{ Model.ContentItem.DisplayText }}</h1>
    <div class="metadata">
        <span>Published: {{ Model.ContentItem.PublishedUtc | date: "%B %d, %Y" }}</span>
        <span>By: {{ Model.ContentItem.Author }}</span>
    </div>

    {% shape_remove_item Model.Content "TitlePart" %}
    {{ Model.Content | shape_render }}
</article>

Example: Custom Summary Template for Lists

Admin template name: Content_Summary__BlogPost

<div class="blog-post-summary">
    <h2><a href="{{ Model.ContentItem | href }}">{{ Model.ContentItem.DisplayText }}</a></h2>
    <p>{{ Model.ContentItem.Content.HtmlBodyPart.Html | strip_html | truncate: 200 }}</p>
    <small>{{ Model.ContentItem.PublishedUtc | date: "%B %d, %Y" }}</small>
</div>

Upgrading from 3.x

template editors; users also need ManageLiquidTemplates. Editor keeps it

through a migration, custom roles must be granted it.

instead of {{ ... .Html | raw }}: HTML and Markdown source is no longer

sanitized on save.

they can now read every public property and field reachable from the shape

model (member names are case-insensitive) without a member-access

registration; User and Site still expose only their fixed members. Module

code that registers filters, tags or values must move to

TemplateOptionsBuilder (see orchardcore-liquid).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.