3

How to fetch the list of all the localized and locally created Components in a Folder for a particular Publication using core service?

Currently I am first fetching all the Components using the following code.

public static IEnumerable<XNode> GetFolderItems(string folderUri, ItemType itemType)
{
    OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData();
    IEnumerable<XNode> folderItems = null;
    XElement folderData = null;
    filter.ItemTypes = new[] { ItemType.Component };
    filter.Recursive = true;
    folderData = Client.GetListXml(folderUri, filter);
    folderItems = folderData != null ? folderData.Nodes() : null;
    return folderItems;
}

After fetching the Folder Components, then for each Folder item I call the following method to fetch the localized/locally created status.

public static bool GetComponentLocalizedStatus(string componentUri)
{
    ComponentData componentdata;
    bool status = false;
    componentdata = Client.Read(componentUri, new ReadOptions()) as ComponentData;
    if (componentdata.BluePrintInfo.IsShared == false)
    {
       status = true;
    }
    else
       status = false;
    return status;
}

This approach is not efficient. Is there a way to fetch the locally created/ localized Components present in a Folder in single go?

1 Answer 1

4

Yes, there is; you can get the BluePrint state (IsLocalized/IsShared) included in the list data using filter.BaseColumns = ListBaseColumns.Extended

2
  • Thanks for your inputs Rick, they are quite useful. I have one query , is it possible to apply filter on "IsShared" property so that returned results are already filtered. Commented May 6, 2015 at 8:01
  • No, it isn't, but you can easily do your own post-filtering using XPath or LINQ. Commented May 6, 2015 at 20:05

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.