3

I would like to get all Pages using a Component that are in the current Publication, as shared from a Parent or a local Page.

Component and Page are in Blueprint Parent. Page is sometimes localized on other Publications (not this one, and do not want those). I want to get the Pages within this Publication and the Parent, but not other siblings.
However, my code gets all Pages in the system using the Component, the same results as the Tridion 'WhereUsed' functionality does in the GUI. (Which is correct behavior, I guess).

Below my code that gets all Pages everywhere.

Maybe I'll have to write some extra code that gets the Blueprint parents of my current Publication and if the Page is found there then add it to my results, but I hope not.

UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData
{
    BaseColumns = ListBaseColumns.Default, // to specify the detail in the XML
    ItemTypes = new[] { ItemType.Page, ItemType.Component} ,
    IncludeLocalCopies = true                
};

XElement usingXML = client.GetListXml(compUri, usingItemsFilterData);
1
  • is there a way to use UsingItemsFilterData so that it returns only those using-items that are published along with used item i.e. compuri here (client.GetListXml(compUri, singItemsFilterData)
    – arjun
    Commented Jun 4 at 2:58

1 Answer 1

5

To get the results from a particular repository, UsingItemsFilterData object has a property InRepository.

UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData
            {
                BaseColumns = ListBaseColumns.Default, // to specify the detail in the XML
                InRepository = new LinkToRepositoryData(){IdRef="tcm:x-y-z"},
                ItemTypes = new[] { ItemType.Page, ItemType.Component },
                IncludeLocalCopies = true
            };

after setting the proper value, the results will be constrained by the specified InRepository value in the filter. So, if the value is set to a TcmUri of a Repository, only items in that Repository will be included in the results.

As Mentioned in comments by @David Forster, if the property "InRepository" excludes the shared items from parent. you have two options:

  1. fire the client.GetListXml twice for parent and local publication and join the results.

  2. Don't use the "InRepository" property and filter the resulting xml for the parent and local publication.

7
  • 3
    using "InRepository" will then exclude shared pages which contain the component. Robert requires these I think. Commented Mar 26, 2015 at 15:01
  • Thanks for the answer. But, how can I get the Parent publication? For me it could be from a global English level or a translation level.
    – robrtc
    Commented Mar 26, 2015 at 15:45
  • you can use the "Parents" property of publicationdata object var pubData = (PublicationData)client.Read("tcm:0-x-1", new ReadOptions()); pubData.Parents Commented Mar 26, 2015 at 16:17
  • 1
    I'm thinking to do a unique filter (linq) on the item ID to get a smaller list, and then for each item in the list make a new URI, using the WhereUsed ID and the Component's Publication ID, and then do a Core Service read with the new URI to see if it exists, and I could then assume it is a shared item. :) A long way to go to get it, but I guess it will work
    – robrtc
    Commented Mar 26, 2015 at 17:02
  • 1
    About the previous suggestions, I guess the best explanation is 'you can't get there from here...' and there is no simple or clean way to get this information using the all-powerful GetListUsingItems...
    – robrtc
    Commented Mar 26, 2015 at 17:03

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.