i am able to find out if the Components is published to a list of target typer or not,below is my approach :

  1. Create a method to find out all the Available target types for the particular publication
  2. Create a method which will take "All available target types" and "list of targets to check" and will return true if "All available target types" Contains "list of targets to check"

Simmilar way i can find out if a component is not published to a list of target types

Is there any good way to do the same ?

2 Answers 2


I have written a core service method to do this recently. You will need to pass in a string array of Publish Target URIs. Also, this works up to Tridion 2013, but not in Sites 8 / 9, as they change the publishing API there to include the new Business Process Types (BPT). The idea is to get all the pages, and then ask the core service for each page, if it is published. It is not very fast, but it works.

        private List<TridionPage> GetPublishedPages(CoreServiceClient client, string rootSgUri, string[] pubTargets)
            OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData();
            filter.ItemTypes = new ItemType[] { ItemType.Page };
            filter.Recursive = true;

            XElement pageElements = client.GetListXml(rootSgUri, filter);
            int count = pageElements.DescendantNodes().Count();
            List<TridionPage> publishedItems = new List<TridionPage>();
            List<TridionPage> notPublishedItems = new List<TridionPage>();

            foreach (XElement pageXml in pageElements.Elements())
                string pageUri = pageXml.Attribute("ID").Value;

                foreach (var pubTargetUri in pubTargets)
                    bool isPagePublishedToTarget = client.IsPublished(pageUri, pubTargetUri, true);  // isPublishedInContext = true
                        TridionPage pageItem = GetPageItem(client, pageUri, pubTargetUri);

                        // Add the Publish Target Info
                        if (pageItem.PublishDetails != null)

Also, the same logic can be used for Components, just search in the Building Blocks folder and also change the filter as below:

//  Below 3 lines to filter for Components
     OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData();
     filter.ItemTypes = new ItemType[] { ItemType.Component };
     filter.Recursive = true;
// End Comp filter

For published case:

You could achieve using the core service by configuring all the dynamic component template Ids and target Ids and then process to Resolve Items based on each component template Id and target Ids.

If you don't know the details of dynamic component templates Ids then first find out all the DCP templates then resolve items based on each CT Id and target Ids.

Example core service code:

//TODO - You could find out either dynamically or configure it as below

//List of DCP component templates
string[] componentTemplateIds = ConfigurationManager.AppSettings["CTTcmIds"].Split(new string[] { "," }, StringSplitOptions.None);

//List of publishing targets
string[] targetIds = ConfigurationManager.AppSettings["PublishingTargetTcmIds"].Split(new string[] { "," }, StringSplitOptions.None);  

var resolveInstruction = new ResolveInstructionData { IncludeChildPublications = false, Purpose = ResolvePurpose.RePublish };

foreach (string cpId in componentTemplateIds)
       var resolvedContexts = client.ResolveItems(new[] { cpId }, resolveInstruction, targetIds, new ReadOptions());

        List<ComponentPresentation> componentPresentations = (
            from resolvedContext in resolvedContexts
            from resolvedItem in resolvedContext.ResolvedItems
            select new ComponentPresentation
                Component = resolvedItem.Item,
                Template = resolvedItem.Template

        Console.WriteLine($"Found {componentPresentations.Count} published Component Presentations based on Id: {cpId}");

For unpublished case:

You can resolve Instruction data Purpose to Publish for that DCP template Id and target Ids to get all list of components and then you can use the above-published list to exclude to get the non-published component items.

var resolveInstruction = new ResolveInstructionData { IncludeChildPublications = false, Purpose = ResolvePurpose.Publish };

I hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.