Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clear all items from a publish transaction for a certain publication. This can be used to implement publish in child publications functionality without publishing content in the parent (master) publication. See https://gist.github.com/willprice76/9639405 for a start point, you will want to put a check to see if the status is Success before delet…
using System;
using System.Collections.Generic;
using Tridion.ContentManager;
using Tridion.ContentManager.Publishing;
using Tridion.ContentManager.Publishing.Resolving;
namespace Example.Resolvers
{
/// <summary>
/// Example resolver to clear all items from publish transactions in certain publications. This can be used as is, or in combination with the
/// event system, to remove these empty transactions from the publish queue
/// </summary>
public class ExampleResolver
{
public void Resolve(IdentifiableObject item, ResolveInstruction instruction, PublishContext context, global::Tridion.Collections.ISet<ResolvedItem> resolvedItems)
{
var noPublishConfig = new List<int> { 18, 20 };//Load your master publication ids in from config however you like
if (noPublishConfig != null & noPublishConfig.Contains(context.Publication.Id.ItemId))
{
resolvedItems.Clear();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment