-2

Using Tridion Core Service, how can I get all the items in a folder?

Kevin Brydon
  • 12,524
  • 8
  • 46
  • 76

2 Answers2

14

You need a filter (OrganizationalItemItemsFilterData).

Then you need to call client.GetList(folderId, filter) to get the list of items in that folder.

OrganizationalItemItemsFilterData filter = new OrganizationalItemItemsFilterData();
foreach (XElement element in client.GetListXml("tcm:3-640-2", filter).Nodes())
{
    Console.WriteLine(element.Attribute("ID").Value);
}
Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
3

A good example on how to use the Core Service which contains all sorts of read operations (like reading a single item and getting a list of items) is shown in the following eXtension on SDL Tridion World: Item Selector Custom URL

The download on SDL Tridion World comes with complete source but this can also be found directly on Google Code where it is hosted as an open source solution. The actual Core Service code can be found in the UserControls/TridionTreeView.ascx.cs Class.

Bart Koopman
  • 4,835
  • 17
  • 30