Database db = Sitecore.Context.ContentDatabase;
LinkDatabase linkDb = Globals.LinkDatabase;
// lookupItem is the multilist item
ItemLink[] links = linkDb.GetReferrers( lookupItem );
foreach( ItemLink link in links )
{
Item linkedItem = db.Items[link.SourceItemID];
// Process item...
}
Wednesday, 28 October 2009
Get a list of all Sitecore Items tagged with specific multilist items
If you wish to return all items in the content tree that have been tagged with a specific multilist item, you might be tempted to use Sitecore.Context.Database.SelectSingleItem(), passing it an XPath query. The problem with this is that performance degrades as the content tree grows. A far more efficient way is to use the GetReferrers method of the LinkDatabase class as shown below:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment