Configures live draft preview in Orchard Core content editing. Covers PreviewPart, PreviewPartSettings, PreviewAspect, BroadcastChannel live updates, and multi-node distributed cache.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an Orchard Core expert. Generate configuration and content definitions for live preview of an editor's in-memory draft without publishing it.
OrchardCore.ContentPreview feature. Its module dependency is OrchardCore.Contents.ContentPreview_Button shape, hidden by placement for menu items and dashboard widgets) to content editors. The button uses resource authorization for Preview content (OrchardCore.Contents.CommonPermissions.PreviewContent, including owner and per-type variants); the draft and display endpoints also require it.PreviewPart only when a decoupled frontend needs a custom URL that should render the draft. The core preview UI works without it.PreviewPartSettings.Pattern to a Liquid path. The pattern is rendered with Model and ContentItem./, such as {{ ContentItem | display_url }} or /articles/{{ ContentItem.ContentItemId }}. Do not include a host or scheme; line breaks are stripped. External headless frontends cannot be preview targets.IDistributedCache for five minutes with sliding expiration and are keyed by an opaque preview token (not a credential). In multi-node deployments configure a shared distributed cache (e.g., Redis), or display requests on another node return 404.BroadcastChannel. Updates are debounced for 500 ms, in-flight requests are aborted by newer ones, and the preview swaps between two iframes to keep scroll position.ContentPreviewFeature.Instance (with Previewing == true) is placed in the current request features during a preview request. Drivers and handlers should check it to skip side effects (Orchard Core uses it to skip indexing and media moves).PreviewPart causes PreviewStartupFilter to re-execute the frontend pipeline with the preview path. This lets the real frontend route, theme, and scripts render the draft.{ "steps": [...] } format.sealed modifier, except View Models.{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.ContentPreview"
],
"disable": []
}
]
}
PreviewPart has no persisted fields. Its type-part setting supplies the frontend path pattern.
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentPreview.Models;
using OrchardCore.Data.Migration;
namespace MyModule;
public sealed class Migrations : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager;
public Migrations(IContentDefinitionManager contentDefinitionManager)
{
_contentDefinitionManager = contentDefinitionManager;
}
public async Task<int> CreateAsync()
{
await _contentDefinitionManager.AlterTypeDefinitionAsync("LandingPage", type => type
.Draftable()
.Versionable()
.WithPart("TitlePart")
.WithPart(nameof(PreviewPart), part => part
.WithSettings(new PreviewPartSettings
{
Pattern = "/landing-pages/{{ ContentItem.ContentItemId }}",
})));
return 1;
}
}
| Setting | Type | Description |
|---|---|---|
Pattern | string | Liquid template that builds the frontend path for the draft. |
The handler populates PreviewAspect.PreviewUrl only when the pattern is non-empty. It strips line endings from the rendered result.
{
"steps": [
{
"name": "ContentDefinition",
"ContentTypes": [
{
"Name": "LandingPage",
"DisplayName": "Landing Page",
"Settings": {
"ContentTypeSettings": {
"Draftable": true,
"Versionable": true
}
},
"ContentTypePartDefinitionRecords": [
{
"PartName": "TitlePart",
"Name": "TitlePart"
},
{
"PartName": "PreviewPart",
"Name": "PreviewPart",
"Settings": {
"PreviewPartSettings": {
"Pattern": "/landing-pages/{{ ContentItem.ContentItemId }}"
}
}
}
]
}
]
}
]
}
PreviewController.Draft.ContentItem, applies editor updates, validates it, and populates PreviewAspect.contentpreview:<token>.PreviewController.Display with the token.PreviewStartupFilter reruns the request pipeline using that path. Otherwise the controller renders the detail shape through its MVC view.Do not persist a preview draft from custom code. The feature deliberately keeps it transient and authorization-protected.
During both Draft and Display, the controller places ContentPreviewFeature.Instance in the current HttpContext.Features. The editor update pipeline and custom update handlers still run against the temporary item, so avoid writes, queued work, or external calls while previewing:
using OrchardCore.ContentPreview;
var isPreview = httpContext.Features.Get<ContentPreviewFeature>()?.Previewing == true;
if (isPreview)
{
return;
}
Keep this logic narrowly scoped, and do not create a second preview cache or bypass the content manager session.
Live updates are driven by editor hooks, not a fixed list of field types:
| Editor behavior | Integration |
|---|---|
| Text-like control | Add the content-preview-text CSS class (input events trigger an update). |
| Select, checkbox, toggle | Add the content-preview-select CSS class (change events trigger an update). |
| Rich or JavaScript editor | Dispatch the contentpreview:render event on document after writing the value to a form control. |
<input asp-for="Value" class="form-control content-preview-text" />
// The preview script listens with addEventListener, so dispatch a native DOM event.
document.dispatchEvent(new CustomEvent('contentpreview:render'));
The module serializes the whole editor form with FormData, so values held only in JavaScript, disabled controls, and file inputs are not sent. BagPart and FlowPart editors trigger a render after every drag-and-drop operation.
When a Liquid pattern is not enough, provide PreviewAspect from a content handler instead of using PreviewPart:
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Handlers;
namespace MyModule.Handlers;
public sealed class ProductPreviewHandler : ContentHandlerBase
{
public override Task GetContentItemAspectAsync(ContentItemAspectContext context)
{
if (context.ContentItem.ContentType != "Product")
{
return Task.CompletedTask;
}
return context.ForAsync<PreviewAspect>(aspect =>
{
aspect.PreviewUrl = $"/products/{context.ContentItem.ContentItemId}";
return Task.CompletedTask;
});
}
}
Register it with services.AddScoped<IContentHandler, ProductPreviewHandler>();.
IContentManager or the normal display pipeline so the IContentManagerSession can return the cached draft.CommonPermissions.PreviewContent; a missing or expired cache entry returns 404.PreviewPart still render their preview in the module's MVC display view with the detail display type.| Symptom | Check |
|---|---|
| Preview button is absent | Enable OrchardCore.ContentPreview and verify the user can preview content. |
| Preview opens the fallback renderer | Attach PreviewPart and configure a non-empty Pattern. |
| Frontend route shows published data | Ensure the route resolves content through the normal request-scoped content manager session. |
| Preview expires unexpectedly | The cache entry uses a five-minute sliding expiration; save or reload the preview to refresh it. |
| Window opens but doesn't update | Keep the editor open, check BroadcastChannel support, and make sure the custom editor uses a hook above. A jQuery $(document).trigger(...) does not reach the native listener. |
| Preview is unstyled | The minimal fallback layout is used; attach PreviewPart with a route that renders through the active theme. |
Preview returns 404 on a web farm | Configure a shared IDistributedCache. |
| Preview shows an older value | The latest values failed validation (the draft endpoint returns 422); the window keeps the last successful render. |
document.dispatchEvent(new CustomEvent('contentpreview:render')) instead of $(document).trigger('contentpreview:render').What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
orchard-core, content-preview, draft-preview, liquid-patterns
/orchardcore:orchardcore-content-previewfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job