Return to doc.sitecore.com

Valid for Sitecore 5.2, 5.1.1
  GetParentID
Prev Next

GetParentID returns the Sitecore ID associated with the given item’s parent.

public override ID GetParentID(
  ItemDefinition item,
  CallContext context
)

Sitecore represents all data as a hierarchy.  That is, all items have a parent and may have children.  Whenever Sitecore needs to locate the parent of a given item, it calls the GetParentID method.  The parent Item ID is returned, as opposed to the actual parent object, to allow the Abstract Data Layer to manage a cache of items.

The following example locates the parent ID using the IDTable class.

public override ID GetParentID(ItemDefinition item, CallContext context) {
  // The following code assumes that this class has an
  // attribute to hold the IDTable called IDs
  IDTableEntry theItem = IDs.GetEntry( item.ID );

  // The IDTableEntry holds the parent ID, so just
  // return that.
  return theItem.ParentID;
}


Prev Next