Orchardcore publish later

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore publish later is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for scheduling unpublished Orchard Core content for automatic publication. Covers PublishLaterPart, scheduled UTC dates, time zones and daylight-saving conversion, programmatic scheduling, PublishLaterPartIndex, editor behavior, admin list (List and Grid layout) display, and the Scheduled Cont

How to use this skill

Skill file

Orchard Core Publish Later - Prompt Templates

Schedule Future Publication

You are an Orchard Core expert. Generate content definitions and integration code for publishing an unpublished latest version when its scheduled time arrives.

Guidelines

Enabling Publish Later

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.PublishLater"
      ],
      "disable": []
    }
  ]
}

Attaching PublishLaterPart with a Migration

using OrchardCore.ContentManagement.Metadata;
using OrchardCore.Data.Migration;
using OrchardCore.PublishLater.Models;

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("NewsArticle", type => type
            .Creatable()
            .Draftable()
            .Versionable()
            .WithPart("TitlePart")
            .WithPart(nameof(PublishLaterPart), part => part.WithPosition("10")));

        return 1;
    }
}

Content Definition Recipe

{
  "steps": [
    {
      "name": "ContentDefinition",
      "ContentTypes": [
        {
          "Name": "NewsArticle",
          "DisplayName": "News Article",
          "Settings": {
            "ContentTypeSettings": {
              "Creatable": true,
              "Draftable": true,
              "Versionable": true
            }
          },
          "ContentTypePartDefinitionRecords": [
            {
              "PartName": "TitlePart",
              "Name": "TitlePart"
            },
            {
              "PartName": "PublishLaterPart",
              "Name": "PublishLaterPart",
              "Settings": {
                "ContentTypePartSettings": {
                  "Position": "10"
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

Scheduling Content in a Recipe

Persist the scheduled instant as UTC. A scheduled item should normally be latest and unpublished.

{
  "steps": [
    {
      "name": "Content",
      "data": [
        {
          "ContentItemId": "[js:uuid()]",
          "ContentType": "NewsArticle",
          "DisplayText": "Conference announcement",
          "Latest": true,
          "Published": false,
          "TitlePart": {
            "Title": "Conference announcement"
          },
          "PublishLaterPart": {
            "ScheduledPublishUtc": "2026-09-01T09:00:00Z"
          }
        }
      ]
    }
  ]
}

Scheduling Programmatically

// draft must be the latest unpublished version of a type with PublishLaterPart.
draft.Alter<PublishLaterPart>(part => part.ScheduledPublishUtc = scheduledUtc);

await _contentManager.SaveDraftAsync(draft);

Convert a local value with ILocalClock.ConvertToUtcAsync first. Set the property to null to cancel.

Editor Behavior

The built-in editor shape appears in the content editor action zone and uses PublishLaterPartViewModel:

| Property | Purpose |

|---|---|

| ScheduledPublishLocalDateTime | Local value bound from the editor. |

| ScheduledPublishUtc | Stored UTC value for display and scheduling. |

| ContentItem | The content item being edited. |

Submitting the cancel action or an empty local date clears the schedule. Do not set a local time directly on PublishLaterPart; convert it to UTC first.

Inspecting Scheduled Items

Use the map index for administrative or reporting queries. Restrict the query to the latest unpublished version.

using OrchardCore.PublishLater.Indexes;
using YesSql;

namespace MyModule.Services;

public sealed class ScheduledPublicationQuery
{
    private readonly ISession _session;

    public ScheduledPublicationQuery(ISession session)
    {
        _session = session;
    }

    public Task<IEnumerable<PublishLaterPartIndex>> GetDueItemsAsync(DateTime utcNow)
    {
        return _session
            .QueryIndex<PublishLaterPartIndex>(x =>
                x.Latest &&
                !x.Published &&
                x.ScheduledPublishDateTimeUtc < utcNow)
            .ListAsync();
    }
}

Background Task Behavior

ScheduledPublishingBackgroundTask publishes each due latest version independently. It obtains the latest item, clears its schedule, logs at debug level, and publishes it. The PublishLaterPartIndexProvider excludes already published or non-latest versions and removes stale indexes when the part is removed from a type definition.

Troubleshooting

| Symptom | Check |

|---|---|

| No scheduling controls | Enable the feature and attach PublishLaterPart to the content type. |

| Content is not published | Verify it is latest, unpublished, and its UTC time has passed. |

| Time is offset | Store and compare UTC values; let the built-in editor use ILocalClock. |

| Old item is published | Confirm an editor did not create a newer draft after scheduling the item. |

| Some due items stay drafts | An exception while publishing one item stops the current run; fix the failing handler, the next run retries. With the Background Tasks feature enabled, check the task is enabled in the /Admin/BackgroundTasks list. |

| Schedule not saved near a DST change | Choose an unambiguous local time. |

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.