Orchardcore archive later

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore archive later is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for scheduling published Orchard Core content to be automatically unpublished (archived) at a future date. Covers ArchiveLaterPart, scheduled UTC dates, ArchiveLaterPartIndex, editor behavior, admin list (List and Grid layout) display, and the Content Items Archiver ScheduledArchivingBackgroun

How to use this skill

Skill file

Orchard Core Archive Later - Prompt Templates

Schedule Future Unpublishing

You are an Orchard Core expert. Generate content definitions and integration code for automatically unpublishing (archiving) a published content item when its scheduled time arrives.

Guidelines

Enabling Archive Later

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

Attaching ArchiveLaterPart via Recipe

{
  "steps": [
    {
      "name": "ContentDefinition",
      "ContentTypes": [
        {
          "Name": "Article",
          "DisplayName": "Article",
          "Settings": {
            "ContentTypeSettings": {
              "Creatable": true,
              "Draftable": true,
              "Versionable": true
            }
          },
          "ContentTypePartDefinitionRecords": [
            {
              "PartName": "ArchiveLaterPart",
              "Name": "ArchiveLaterPart",
              "Settings": {}
            }
          ]
        }
      ]
    }
  ]
}

Attaching ArchiveLaterPart via Migration

using OrchardCore.ContentManagement.Metadata;
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("Article", type => type
            .WithPart("ArchiveLaterPart"));

        return 1;
    }
}

Reading or Setting the Schedule in Code

// Schedule an item to be unpublished 30 days from now (IClock and IContentManager are injected).
var part = contentItem.As<ArchiveLaterPart>();

part.ScheduledArchiveUtc = _clock.UtcNow.AddDays(30);

contentItem.Apply(part);

await _contentManager.UpdateAsync(contentItem);

To find items scheduled for archiving, query the index:

using OrchardCore.ArchiveLater.Indexes;
using YesSql;

var due = await _session
    .QueryIndex<ArchiveLaterPartIndex>(x => x.Published && x.ScheduledArchiveDateTimeUtc != null)
    .ListAsync();

How the Background Task Works

Notes

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.