7

I am using Tom API in SDL Tridion 5.3. I am getting list of components using GetItems method of interface Tridion.ContentManager.Interop.TDS. I need to get the publication targets from which a component is published.

I can get the similar for pages, as shown in below function:

public static Dictionary<string, string> GetFolderPublishedPages(string foldername, TDSE tdse, ItemType type, string[] publishedTo = null, string[] notPublishedTo = null)
    {
    Dictionary<string, string> pagelist = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
    VirtualFolder fldr = null;
    string componentName = string.Empty;

    try
    {
        fldr = (VirtualFolder)tdse.GetObject(foldername, EnumOpenMode.OpenModeEdit, null, XMLReadFilter.XMLReadNull);
        foreach (Page lObjPage in fldr.GetItems(ItemType.ItemTypePage))
        {
            foreach (string targetURI in publishedTo)
            {
                if (lObjPage.IsPublishedTo(targetURI))
                {
                    foreach (string noTargetURI in notPublishedTo)
                    {
                        if (!lObjPage.IsPublishedTo(noTargetURI))
                        {
                            pagelist.Add(lObjPage.Title, lObjPage.ID);
                        }
                    }
                }
            }

        }
    }
    catch (Exception ex)
    {
    }
    finally
    {
        ReleaseComObject(fldr);
    }

    return pagelist;
}

Please suggest similarly if I can do a check for component too..

Thanks in advance..

  • Not that it helps you, but FYI: that's not the TOM.NET, that's TOM with a .NET Interop – Nuno Linhares Jun 19 '14 at 13:33
  • Please specify which version of Tridion you are using, and how your code is running (i.e. is this in a template, a custom page, a command line script etc) – Chris Summers Jun 19 '14 at 14:30
  • just created a tag for "tom", if you want me to remove it because I have overlooked something, then let me know – Pankaj Gaur Jun 19 '14 at 16:07
  • did you get solution for it? – Raj Kumar Aug 7 '14 at 11:13
3

Could you try following. this should provide xml with required info, then you need to parse that XML.

so here yourcomponent is the component returned by GetItems method

yourComponent.GetXml(XMLReadFilter.XMLReadPublishInfoDetails);

Or

yourComponent.GetXml(XMLReadFilter.XMLReadPublishInfo)

Or

    yourComponent.GetXml(XMLReadFilter.XMLReadPublishInfo | 
XMLReadFilter.XMLReadPublishInfoDetails)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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