RefItems

private void Page_Load(object sender, System.EventArgs e)
{
  Sitecore.Context.SetActiveSite("shell");

 

  Database master = Sitecore.Context.ContentDatabase;
  // the Item that is referred to
  Item refItem = master.Items[@"/sitecore/content/home/pdfs/document3"];
  // getting all Items that refer to the Document3 Item
     foreach(Item linkItem in GetLinkedItems(master, Language.Current, refItem))
    {
      Response.Write("Item: " linkItem.Name "
");
    }
}

 

 

private static Item[] GetLinkedItems(Database database, Language language, Item refItem)
{
// getting all linked Items that refer to the "refItem" Item

 

ItemLink[] links = Globals.LinkDatabase.GetReferers(refItem);
  if (links == null)
{
return null;
}

 

   ArrayList result = new ArrayList(links.Length);

   foreach(ItemLink link in links)
{
   // checking the database name of the linked Item
      if (link.SourceDatabaseName == database.Name)
   {
      Item item = database.Items[link.SourceItemID, language];
     // adding the Item to an array if the Item is not null
     if (item != null)
       {
        result.Add(item);
       }
    }
}

  return (Item[])result.ToArray(typeof(Item));
}

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!