How do I control which linked Components are published when I publish a specific Component?

tridion

Solution

What you are experiencing is the default behaviour of Tridion. This is by design, to ensure that when you change content in a component, publishing it will update all instances of that content on the website.

As the other answers suggest you can change this behaviour using a Custom Resolver:

 using Tridion.ContentManager;
 using Tridion.ContentManager.CommunicationManagement;
 using Tridion.ContentManager.ContentManagement;
 using Tridion.ContentManager.Publishing;
 using Tridion.ContentManager.Publishing.Resolving;

public class UpdateResolvedItems : IResolver
{
      public void Resolve(
            IdentifiableObject item, 
            ResolveInstruction instruction,
            PublishContext context, 
            Tridion.Collections.ISet<ResolvedItem> resolvedItems)
      {
           foreach (ResolvedItem resolvedItem in resolvedItems)
           {
             // Check resolved items, and remove accordingly
           }
      }
}

The code example above demonstrates you can get access to a collection called resolvedItems. This is a list of items due to be published, unless you make a change to it.

You can iterate through this list and remove items according to your requirements.

Problem

I am using SDL Tridion 2011 SP1. I have Components A, B and C. Component C is linked with A & B. If I publish C, both Component A and B are getting published. But I want only Component A to be published. Can any one explain how to exclude Component B from publishing?

Original source