Skip to content

Scheduling

AI Context Items integrate with the Scheduler module to support scheduled publishing and unpublishing of context items.

Scheduling is an optional feature. The Scheduler modules are not required to install AI Context, and the scheduling fields stay hidden until you turn them on, even when Scheduler is installed.

How it works

Once scheduling is enabled (see Requirements and Configuration), the Scheduling options section appears in the sidebar when editing a context item. You can set:

  • Publish on -- a future date/time when the item should be published
  • Unpublish on -- a future date/time when the item should be unpublished

When cron runs and the scheduled time has passed, Scheduler automatically changes the item's moderation state.

Skipped scheduled publishing

Cron does not publish an item when saving it as published would break a context item rule. For example:

  • The item is global and the Max global context items limit is reached.
  • The item's parent is itself a subcontext.

The item stays unpublished and keeps its Publish on date. Context Control Center logs a warning under Recent log messages (ai_context type) that names the item and the reason. The rest of the cron run continues. Cron tries again on every run and publishes the item once the rule passes, for example after another global item is unpublished or the limit is raised. The warning is logged again on each run until then.

If an editor saves an item whose Publish on date has already passed and publishing is blocked, the editor also sees a warning message with the reason.

Requirements

Scheduling requires these optional modules:

Install both with Composer and enable them:

composer require drupal/scheduler drupal/scheduler_content_moderation_integration
drush pm:install scheduler scheduler_content_moderation_integration

Enabling Scheduler seeds the AI Context scheduling settings automatically. The date fields remain hidden on the context item form until you turn scheduling on.

Scheduler Content Moderation Integration adds Publish state and Unpublish state fields to moderated entity types. It remembers the Scheduler entity types for the rest of the request. When Context Control Center is installed later in that same request, as in a recipe chain, context items are missing from that list, so the two fields are not installed. Context Control Center installs them itself. Installing the modules in separate requests installs the fields as usual. On a site where the status report shows "The Publish state field needs to be installed" for AI Context Item, run drush updatedb.

Configuration

Scheduling is off by default, even when Scheduler is installed. Enable it on Scheduler's settings form for context items at /admin/config/content/scheduler/ai_context_item.

When Scheduler is installed, the Context item settings page at /admin/config/ai/context/settings/items shows the current scheduling status and links to that Scheduler form.

Scheduler owns this setting and manages both the configuration and the Publish on / Unpublish on fields on the context item form. Use it to control:

  • Whether publishing scheduling is enabled
  • Whether unpublishing scheduling is enabled
  • Default scheduling behavior

Context item settings at /admin/config/ai/context/settings/items also configure publishing defaults (default_status).

Permissions

The Schedule publishing of AI Context Items permission controls who can set scheduled dates. The View scheduled AI Context Item permission controls who can see items that are scheduled but not yet published.

Use cases

  • Seasonal content: Schedule product-specific context to publish at the start of a sales season and unpublish when it ends
  • Policy updates: Prepare updated compliance context in advance and schedule it to go live on the effective date
  • Temporary context: Publish event-related context for a limited time window