Getting the ancestors of a repository-local object
You can use TOM.NET to retrieve the full set of ancestors (parent, grandparent and so on) for any repository-local object. You can use this information to, for example, construct a breadcrumb trail to the object.
To get the ancestors, first create an object of class Tridion.ContentManager.ContentManagement.OrganizationalItemAncestorsFilter. This class has an IncludePublishLocationColumns property, which you can set in order to also set the following properties or attributes:
PublishLocationUrlPublishLocationPathPublishPath
Other properties of this filter class are:
IncludeAllowedActionColumnsListBaseColumns, which can be set to return ID only (valueId) or ID and title (valuesIdAndTitle,DefaultorExtended).
Next, call the GetAncestors or GetListAncestors method on the item whose ancestors you wish to retrieve; that is, on an object of the Tridion.ContentManager.ContentManagement.RepositoryLocalObject class, or of any of its subclasses. You must at least have read access to the object.
The Core Service also exposes this functionality in its ICoreService class through the GetList and GetListXml methods. Here, you pass an object of class OrganizationalItemAncestorsFilterData.
The methods return one of the following:
- For Keywords, a list containing only the Category to which the Keyword belongs.
- For root organizational items, an empty list.
- For Workflow Process Definitions, an empty list.
- For all other items, a list of items (either as objects or as XML), the first item being the direct parent, the next being the grandparent, and so on, ending with the root organizational item of the Publication.