2

I am looking to get the component resolved in page using core service..

We can find item used in how many places by this

UsedItemsFilterData usedItemsFilterData = new UsedItemsFilterData();
return client.GetListXml(tcmID, usedItemsFilterData)

i need solution for itemType component in which pages it got used and ,does any one having some link or post

2 Answers 2

5

You're almost there.

To determine all pages that use a given component, I would use the following code:

UsingItemsFilterData pagesFilter = new UsingItemsFilterData();
pagesFilter.ItemTypes = new [] {ItemType.Page};
return client.GetListXml(componentId, pagesFilter);
0

To find all component(linked Component) linked to pages

            UsedItemsFilterData filter = new UsedItemsFilterData();
            filter.ItemTypes = new ItemType[] { ItemType.Component };
            XElement xmllist= client.GetListXml("tcm:aaa-bbbb-64", filter);
            //to get list of all component for pages(Level1)
            list = (xBundles.DescendantNodes()).ToList<XNode>();
            foreach (XElement foo in list)
            {
                if (foo.HasAttributes == true)
                    {
                        XElement xmllist2= client.GetListXml(foo.FirstAttribute.Value,filter);//get all component from component(level 2)
                        List<XNode> List2 = new List<XNode>();
                        List2 = (xmllist2.DescendantNodes()).ToList<XNode>();
                        foreach(XElement foo1 in List2)
                            {
//repeat same loop structure to get next level
                            if (foo1.HasAttributes == true)
                                     {
                             //for level 2
                                     }     
                             }

              }  
            }

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.