4

Looking for a sample TOM .NET code how to get all the components of a bundle and then process each component one by one as per their metadata value. Any pointers here , thanks

0

2 Answers 2

4

A bundle is an OrganizationalItem just like a folder or a structure group. You can get the items in the bundle with the GetListItems() method. If you only want to get components, you can use a filter like this:

// session can be obtained from any Tridion object (e.g. a component, page, etc)
var bundle = session.GetObject("tcm:3-123-2") as Bundle;
var filter = new OrganizationalItemItemsFilter(session) 
{ 
    ItemTypes = new[] { ItemType.Component } 
};
var items = bundle.GetListItems(filter);
2

Besides all Q mentioned, you don't even need to use filter. Bundle has all IDs in source:

<Bundle xmlns="http://www.sdltridion.com/ContentManager/Bundle">
    <Items xmlns="http://www.sdltridion.com/ContentManager/Bundle">
        <Item xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="tcm:1-2123" xlink:title="title333"></Item>
        <Item xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="tcm:1-3543" xlink:title="Page details"></Item>
        <Item xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="tcm:1-3453" xlink:title="Battery"></Item>
        <Item xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="tcm:1-34325" xlink:title="Download"></Item>
        <Item xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="tcm:1-345" xlink:title="title2"></Item>
    </Items>

So all you need is just extract IDs from the source using LINQ. One less call to Core service.

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.