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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With